-2

I have noticed that whenever I add a new image to a post or page, 5 or more duplicates of the same images are created in my WordPress wp-content/uploads folder.

How can I stop that?

Raunak Gupta
  • 10,412
  • 3
  • 58
  • 97
Sidney Sousa
  • 3,378
  • 11
  • 48
  • 99
  • May I ask you to be more precise... What media uploader? Any piece of code we can have a look at? – Thibaut Rey Mar 15 '17 at 09:21
  • 1
    @Thibaut Rey. The normal WordPress Media uploader – Sidney Sousa Mar 15 '17 at 09:24
  • Not sure if that could help but sometimes plugins in Wordpress mess around with the image library. I do not think the Media Uploader is the actual problem, it is a well tested part of the CMS. Have a look at the list of your WordPress plugins and see if any of them could be the faulty one. Try disabling them one by one... – Thibaut Rey Mar 15 '17 at 09:29

2 Answers2

0

You can use filter intermediate_image_sizes with an empty array.

add_filter( 'intermediate_image_sizes', '__return_empty_array' );

The above code will disable all kind of thumbnail generation.


To only remove specific image size:
function wh_removeImageSize($sizes)
{
    unset($sizes['thumbnail']);
    unset($sizes['medium']);
    unset($sizes['large']);
    return $sizes;
}

add_filter('intermediate_image_sizes_advanced', 'wh_removeImageSize');

All code goes in function.php file of your active child theme (or theme). Or also in any plugin php files.
All code is tested and works.

Hope this helps!

Raunak Gupta
  • 10,412
  • 3
  • 58
  • 97
0

I just used DNUI plugin that detects and deletes any unused image in the site and it works perfectly. Don't know why exactly the images are being duplicated, but the problem was minimized and controlled.

Sidney Sousa
  • 3,378
  • 11
  • 48
  • 99