WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a setting in my theme that seeks to prevent the WP media manager upload utility from creating multiple copies of each image I upload. Apparently the latest versions of WP have changed the required settings to defeat this?

Here's the current settings I have in my theme's functions.php...

if(get_option('thumbnail_size_h')!==0){update_option('thumbnail_size_h', 0);}
if(get_option('thumbnail_size_w')!==0){update_option('thumbnail_size_w', 0);}
if(get_option('medium_size_h')!==0){update_option('medium_size_h', 0);}
if(get_option('medium_size_w')!==0){update_option('medium_size_w', 0);}

Even with these settings, I'm still getting a duplicate image every time I upload. For example, if my image filename is foo.jpg and it is 800x600 pixels, WP creates two images foo.jpg and foo-800x600.jpg

How can I force WP to not create the duplicate?

share|improve this question
Have you disabled all the intermediate image sizes? If you set all 3 sizes to 0(Admin > Settings > Media), that should result in only one image being created on upload. I have done it on my local installation without a problem, but i have had users report it not working for them(i suspect their theme/plugin(s) is/are defining additional image sizes in those cases though - ie. add_image_size). – t31os Jan 25 '11 at 17:43
up vote 2 down vote accepted

I believe the following should stop thumbnails from being created. If you're wanting to remove some then and unset the $size[{size}]. Following sizes are there "thumbnail","medium","large","post-thumbnail".

function stop_thumbs($sizes){
      return array();
share|improve this answer
Thanks! I'm testing this now. If I can use this instead of my existing get_option getter/setters, then I'd much rather... – Scott B Jan 25 '11 at 19:14
Yep, I've commented out all my getter/setters on thumbs and replaced it with this filter and it works like a charm! Thanks again Backie! – Scott B Jan 25 '11 at 19:19
Would it be possible to make your filter active only when the image is uploaded from "Media > Add New"? I actually want to allow the user to resize the image, but I don't want WP creating thumbs everytime an image is uploaded. I tried wrapping it in if($pagenow=="media-new.php") to no avail. – Scott B Jan 25 '11 at 19:27
How to just stop some image size like Large and thumbnail but keep the medium on with Backie Function ? add_filter('intermediate_image_sizes_advanced','stop_thumbs'); function stop_thumbs($sizes){ return array(); } How to add "thumbnail","medium","large","post-thumbnail" to that code ? – user4895 Apr 26 '11 at 9:41

I just realized that I had not enabled the large_size options...

if(get_option('large_size_h')!==0){update_option('large_size_h', 0);}
if(get_option('large_size_w')!==0){update_option('large_size_w', 0);}

Adding those settings, to my existing settings, effectively stops WP uploader from adding a copy of the image.

share|improve this answer

As @t31os said in the comments, you don't need any code to do this. If you're just looking to disable the default sizes, you just need to set them all to "0" in Admin > Settings > Media.

share|improve this answer
I still want the end user to be able to define thumbs and use them, assuming they choose one of the thumbnail sizes when they upload the image. I just don't want WP to create the thumbs when a user is just uploading an image via Media Manager > Add New – Scott B Jan 25 '11 at 19:38
So, recognizing that WP has to create the thumbs before it can allow you to use any of them, the ideal solution for me would be if I can apply the filter only when the user is uploading via Media Manager > Add New (and not when they are uploading from within a post). – Scott B Jan 25 '11 at 19:40
@Scott B I don't understand what you mean by "assuming they choose one of the thumbnail sizes when they upload the image". You don't choose sizes when you upload the image--you choose them when you insert the image into a post. Both the "Media Manager > Add New" and the "New Post > Add Media > From Computer" use the same upload form, and the same process. From your comments, what I think you're trying to do is not create any additional sizes until a user tries to INSERT (not upload) their image into a post. Is that correct? – MathSmath Jan 25 '11 at 20:09
yes, that's essentially what I want to do, however, I don't think WP is capable of doing that. It appears that the thumbs must be created when the image is first uploaded, or they will not be created at all. So I'm ok with allowing them to be created at upload time, if the user is uploading while editing a post, but I don't want any thumbs to be created if the user uploads an image from the media manager > add new routine. – Scott B Jan 25 '11 at 20:58
@ScottB Hmm... in that case, you can use the filter that @Backie suggested above (intermediate_image_sizes_advanced), and in the hooked function check for a field in the post collection named "_wp_http_referer". It tells you where the upload request came from. If it contains "media-new.php", you can return an empty array (which will temporarily stop thumbnail generation, but won't actually change any thumbnail settings). Otherwise, return the $sizes array untouched. – MathSmath Jan 25 '11 at 21:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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