I bet you are not aware of what happens when you upload a photo to your WordPress website? In fact, you probably don’t realize that one image could generate multiple duplicates. This can be a serious problem with hundreds, if not thousands of unused images filling up your media library. This can cost you a lot of time and money.
I did not realize until I noticed that my site backups were getting huge and my web server was losing disk space faster than it should. I discovered that my media folders (where your uploaded images are stored) were filling up with tons of images, each one being duplicates of the original but with different dimensions.
How WordPress Post Thumbnails are Created
There are many ways post thumbnails are generated, so I will give you a few examples. The first is going to be the most common method which is WordPress itself. When you install WordPress, there is a setting that has 3 default dimensions for post thumbnails.
As you can see, the three media settings are filled in for you already. Every time you upload a photo, a copy will be generated with each of the dimensions you see above. This of course is if your uploaded image is at least 1024 pixels in size.
When each post thumbnail is generated, the file name gets the size appended to it. For example, if your image file is named myphoto.jpg and you have the above media settings, each copy will be renamed as:
After uploading, you won’t see each copy in your media library except the original photos:
So for each photo that you upload in our example, you will get 4 post thumbnails of the same image…even if you don’t use any of them.
Theme Generated Post Thumbnails
Another method that generates thumbnails are themes. If your theme uses or offers thumbnail create for specific things like recent, related, or even portfolio content, thumbnails will get generated. This means that you will get more images added to the existing set of thumbnails. You could easily go from 4 thumbnails to 8, all from the same uploaded image!
If a theme also creates post thumbnails, your media folder could look something like this example of me uploading a photo named gallery5 as the original image:
As you can see, this is just one image, so think what your folder will look like with other uploads.
Plugin Generated Post Thumbnails
Not only will WordPress and themes create thumbnails, some plugins can also do this. Gallery or Portfolio based plugins are probably the most common. This is usually the case if they generate a layout that has consistent sized images for a unified style.
Why is this a Problem?
If your website generates so many unused images, but you don’t use them, this adds bloat to your website file inventory. The problem can quickly fill up your disk space with your hosting account and even slow down your website. As you know, when you sign up for a hosting package, you get a certain amount of disk space. Any website that uploads a lot of images will fill up this space quickly which means your host will tell you to upgrade. This means more cost to you.
Another issue is backing up your website. The more unused thumbnails that exist, the bigger your backup file (archive) becomes. So if every image you upload generates more copies, the file size also increases–dramatically! For example, what should be a 100 MB backup, could balloon up to 400 MB or more.
To give you another example, I was working on another website and had the job of cleaning out all the extra unused thumbnails for 3 years, 2017, 2018, and 2019. Each year having 12 folders, each one representing a month. Here is just one folder that contained over 11 MB of unused post thumbnails:
…and that is just for the month of June (06). After cleaning out the extras, it dropped down to just over 1 MB. In total, the whole year of 2018 saved just over 90 MB of space!
One more issue relating to backups, is that the larger the archive, the more time it will take and has the potential of server time-outs.
A Few Solutions to Prevent This Problem
Now that I’ve gone through some of the issues relating to excessive post thumbnail creation, let’s talk about how to prevent and/or fix the problem. It’s going to best to prevent the problem from happening in the first place, but this might not be a choice.
Disable the WordPress Media Settings
This is the easiest solution because you have direct access to the settings. Basically you go to your Media Settings of your WordPress admin and in each box, change the values all to 0 (zero) and then save. Doing this means that each image you upload, no copies of it will be generated; just the original will exist.
The only one that might be relevant is the “thumbnails” setting. including the option to check the box next to “Crop image to exact dimensions…”. If you plan on using the WordPress Gallery Shortcode and want your thumbnails to be consistent in size, then you can set your size here.
A lot of themes, even here at Rough Pixels, will have custom thumbnail sizes that will generate anywhere from 1 to as many as 6 on average. They usually cover things from a post featured image, recent posts widget (with thumbnails), a portfolio, perhaps even a related posts thumbnail.
What I’ve found is that many themes have this function enabled by default which means you get them whether you want them or not. However, here at Rough Pixels, we have settings in the customizer that lets you enable/disable this function.
With our themes, you simply head over to the thumbnails tab of the customizer theme options and disable any active thumbnail crop setting. For themes from other locations, check to see if they give you that choice. As a last resort, if a theme does not have this capability, you can look for a piece of code in the functions.php file that looks something like:
add_image_size( 'recent-post-thumb', 90, 90, true );
When you find it, remove it.
NOTE: If you plan on editing any theme file, it’s best to create a child theme to do it, otherwise when your theme gets an update, you will lose your custom changes.
Another option is to use a plugin, such as trying out called Stop Generating Image Sizes.
If you are using plugins for galleries, portfolios, or anything else that generates thumbnails, check its settings. If the plugin includes thumbnail management, you might be in luck, but if not, that could be a problem. Your options for this would be to find an alternative plugin or perhaps contact the plugin developer on how to disable its thumbnail creation.
Create Your Own Thumbnails
One of the options you have is to make your own thumbnails before uploading. I know it’s a bit more work, but it does give you greater control. Use your preferred photo editing application/program to adjust, optimize, and crop your images.
In a sense, you are making your post thumbnails on a per-need-basis.