1

I am using a bit of code, that deletes the unneccessary full images after uploading and adding different sizes.

deleting function in functions.php:

add_filter( 'wp_generate_attachment_metadata', 'delete_fullsize_image' );
function delete_fullsize_image( $metadata )
{
$upload_dir = wp_upload_dir();
$full_image_path = trailingslashit( $upload_dir['basedir'] ) . $metadata['file'];
$deleted = unlink( $full_image_path );

return $metadata;
}

So, that works great, but the problem is I can not see any thumbnails in the media library anymore as they are generated by the full size image only, it seems. This makes it really complicated/hard to work with the uploaded images.

Is it somehow possible to "repair" this and and get those little thumbnails in the media library from another size (like medium, large or any custom named size)?

Thank you in advance, guys.

1 Answer 1

0

What is the need to remove the full size images? Are you dealing with storage space? If not, why give yourself the headache? Just let the full size images stay where they are. You don't have to use them. You'll probably find a situation where you want to use it anyways.

Also, I've never tried it, but you might be able to disable default image without deleting it by adding the following to your functions.php file:

update_option('full_size_w', '0');
update_option('full_size_h', '0');

You could also customize which image sizes display as an option in the editor as shown here.

1
  • Hi Uni, two reasons for the deletion: 1. Storage space. 2. Security. I do not want anyone to have access to full size images, which then can easily used elsewhere, even printed. --- I copied your code to my child's functions.php and the thumbnails have returned. :D Thank you very much. I just do not understand why. Care to elaborate?
    – vega
    Apr 25, 2014 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.