Question

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?

Was it helpful?

Solution

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".

add_filter('intermediate_image_sizes_advanced','stop_thumbs');
function stop_thumbs($sizes){
      return array();
}

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top