I am writing a theme which uses different image sizes.

Here are my targeted sizes as they are set up in under Settings > Media in WP Admin:

enter image description here

Here is the functions.php code for the thumbnail support:

$LARGE_SIZE = 1366;

if (function_exists('add_theme_support')) { 

  set_post_thumbnail_size(        $THUMBNAIL_SIZE,  9999);
  add_image_size( 'medium-size',  $MEDIUM_SIZE,  9999 ); 
  add_image_size( 'large-size',  $LARGE_SIZE, 9999 );

So, as you can see, the sizes are 320px wide, 460px wide and 1366px wide.

The problem is, when I upload a 1366px wide image it uploads the original file and additionally creates 320px, 460px and 1366px resized images.



  • someimage.jpg (which is 1366px wide)

OUTPUT (in /uploads/2015/08/)

  • someimage.jpg

  • someimage-1366x937.jpg

  • someimage-460x316.jpg

  • someimage-320x220.jpg

What I can see is that the autocreated someimage-1366x937.jpg is compressed, which I am not really anticipating.

In my previous experience if the uploaded image had the same size as the largest specified size, it did not create a duplicate.

I don't need these duplicated images with the same width as the original upload, they are just wasting storage space.

I am using Wordpress 4.3. No plugins are added yet, so it's definitely something that is the Wordpress core is doing, I haven't experienced this before updating version 4.3 (I used a version 4.0 before and picked up developing WP again after 4.3 came out.


Here is my image editing process.

I always resize the image to the largest size needed. Some posts need 1366px wide images, some only need a 460px wide image.

Whatever scenario applies, I want Wordpress to take the image I upload and not to recreate a compressed duplicate of it. Additionally, it has to create all the smaller sizes.

This means:

  • 1366px upload --> create 460px and 320px

  • 460px upload ---> create 320px

1 Answer 1


If you are uploading images the same size as the large size in your WordPress installation, then set your Large size to 0x0 in Settings -> Media or remove this line:

add_image_size( 'large-size',  $LARGE_SIZE, 9999 );

EDIT #1:

Try to add this filter to delete the original image:

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;

It will delete the original image after upload and keep only the generated ones.

EDIT #2:

Check these two plugins (untested), they might help you do it automatically:

  • The problem is that occassionally I upload 460px wide images too. So I need a solution that handles resizing for all possible sizes.
    – imrek
    Commented Aug 24, 2015 at 9:28
  • What I also see is that I had no problem using this code on WP 4.0, and suddenly this issue popped up.
    – imrek
    Commented Aug 24, 2015 at 9:29
  • Please see the UPDATE seciton in my post.
    – imrek
    Commented Aug 24, 2015 at 9:32
  • Do you really have to add the code in functions.php file? It basically does the same as the settings in your Media section. I think your problem is because you don't specify a fixed height, that's why WordPress duplicates your images. Regarding your last comment, WordPress 4.3 changed lots of stuff in the media part of the code.
    – Ciprian
    Commented Aug 24, 2015 at 9:36
  • 1
    Let me know how it works. I want to implement the same behaviour in a site I'm developing now and I need to keep disk space at a minimum.
    – Ciprian
    Commented Aug 24, 2015 at 9:48

Your Answer

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

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