By default, WordPress automatically generates three copies of a single uploaded image via its media uploader;
That means if you upload one image, there will be total four images on your hosting account.
Why WordPress creates different sizes of images
WordPress creates multiple sizes for an uploaded image, and practically it is legitimate. For better SEO and for a lot better speed, it is a good practice to serve scaled images. For instance, you have uploaded a large image with 3500X2000px, and you don’t create a thumbnail size for it, the entire big image will be loaded as a thumbnail (resized), that will remarkably impact site loading time as there are many thumbnails on a single page. WordPress creates a small-sized thumbnail copy for all images, and this tiny sized copy is served as a thumbnail and thus decreases the page load time significantly.
So I advise you not to disable thumbnail creation by WordPress. But, yes, you should disable creation of Medium and Large copy of an image, and it is very easy to do.
How to disable different size generation of an uploaded image by WordPress
Access your WordPress admin panel
- Go to settings > Media
- Here adjust the size value to zero for any size that you want to disable and then save the changes. On doing so, your hosting account will not be messed up with unnecessary image accumulation. There will be generated only thumbnail size, and we can’t neglect the importance of thumbnail size in terms of SEO.
If you are seeing that unusual number of sizes is generated which may be up to 15-20, and aforementioned method is unable to prevent this one hell of accumulation of unnecessary image copies, you may be in trouble. Buddy, things may come to a head, if you ignore this issue. Such a a large amount of images are started to pile on your hosting account, and soon your account will be bared by provider on account of exceeding inode limit.
The question arises is, what is the real culprit behind this issue? And the answer is – Your WordPress theme
Your WordPress theme can register as many sizes as it want and the code related to it is most likely in theme function.php. To disable these extra registered image sizes, you need to locate the piece of code and to delete that.
How to find image sizes related functions in function.php?
Go to your hosting file manager and edit function.php that exists in theme folder or in a sub folder. Search the following text add_image_size. Thus you can delete any image size you want.
However, finding code regarding image sizes may be difficult in some themes. That is why, I am telling you the unfailing way to disable desired image sizes.
EWWW Image Optimizer plugin
It is the best WordPress plugin to optimize and compress uploaded images to reduce the load on the server. Additionally, it offers some other utilities, including “Disable Resizes” feature. With the help of this speciality you can disable any image size just using your mouse. EWWW Image Optimizer lists all image sizes with an attached checkbox. To disable any image size, you need to tick checkbox.
How to delete existing multiple copies of a single image
You can prevent WordPress from creating different versions of images but how will you delete the junk that already piled on? I found no effective plugin that could identify image copies and delete them. We tried an outdated plugin “Image Cleanup” but it didn’t solve the purpose. Then we gave PW Image Cleaner by Pimwick a try. It successfully identified all unused copies of images. But to delete all those duplicate images this plugin asked to upgrade to its pro version that cost $20. If you need to clean all these image with one click, shelling out 20 bucks is not a bad choice.
But I like experiments and after racking my brain for a few minutes I found a way to get rid of these multiple image sizes already generated by WordPress core or a theme. I decided to use FileZila FTP client to delete thousands of unused size variants that are increasing WordPress’ upload folder size several times.
Warning – be careful using this method. It may delete some non-duplicate files. SO better to take backup of your upload folder before proceeding with this method.
How to find and delete files in bulk with FileZilla
- FileZilla is a free FTP client that works like a charm. First of all get into your WordPress directory using FTP credentials.
- First of all access any subfolder of uploads folder and identify the file size that you want to delete
- Use FileZilla’s server > search remote files feature
Add the width of duplicate file (every duplicate image file contains width and height information in the end of its name. For example if you upload a file named xyz.jpg, then it may have following size variants;
In these example image sizes, 1024 and 150 are the width of these duplicate images.
In FileZilla remote file search panel add two file filters
- file name > contains > -1024x
- file name >contains > -150x
- Here we have added – and x before and after the width to prevent accidental deletion of some files that contains 1024 or 150 in their original name.
- FileZilla will list all files that contains this text in their name
Select all the listed files (Ctrl A) and delete them