Managing images in WordPress is a simple task if taken care at the beginning of building your site. Else it will become a cumbersome task to cleanup your files at later stage when your site has grown larger in size. Each image you upload in your WordPress site will generate multiple thumbnails to display it in various places like recent posts, featured posts, header slideshow, etc. Since most hosting providers have restriction on file count at account level it is necessary for each WordPress site owner to manage images effectively by restricting the number of thumbnails generated.
1. How Thumbnails are Generated in WordPress?
WordPress generates thumbnails in one of the following three ways:
- Thumbnails generated by default media settings in WordPress
- Theme generated thumbnails
- Thumbnails generated by a plugin
2. What Causes Thumbnail Accumulation?
There will be lot of unnecessary images accumulated over the period of time when you are running a blog for many years. Some of the reasons could be:
- You have changed the theme in-between.
- You have added many plugins in-between.
Both the above scenarios are very common for a site running for long time. The theme and most of the plugins will generate thumbnails in addition to the default thumbnails generated by WordPress. In an average all those decorative themes will generate around 10 to 20 thumbnails for each single image you upload on your WordPress site. Below is an example count of thumbnail generation in a WordPress site – the actual count may differ based on your theme and plugins:
|Thumbnails Generated by WordPress Media Settings||3|
|Thumbnails Generated by Theme||10|
|Thumbnails Generated by a Plugin||2|
Default themes like twenty fourteen offered by WordPress will generate three thumbnails in normal, medium and large sizes based on your media settings. Other complex themes will register various sizes of thumbnails in functions.php file. These thumbnails are then used in places like featured image, recent post, featured post, popular post, related post, etc. Choosing the right theme is one of the important factors in running a successful WordPress site. Most of the users choose free themes at the start and struggle to migrate later when the site grows in size. All those attractive free and premium themes showcasing multiple images on the demo pages are really not useful for practical purposes.
Also plugins for sliders, galleries, reviews, etc. will generate thumbnails to display it in appropriate places.
3. Why Do You Need to Cleanup Thumbnails?
The simple reason to cleanup the thumbnails is to reduce the file count limit of your hosting account as decided by the hosting service provider. As explained in the above table, if your site has 2000 images then the total final file count will be 2000*16=32000. This is more than sufficient to reach the threshold of 50000 files if you use Bluehost for example.
Besides file count limit, each image in a web page will send a separate HTTP request to server thus increasing the page loading time. Hence, use images only if it is required and reduce thumbnails as much as possible. Learn more about optimizing images on WordPress.
When you migrate one theme from other or adding/deleting plugins on your site, old accumulated thumbnails will be left alone on the server without any use. You should periodically cleanup these thumbnails and regenerate new ones required for your installation for the below reasons:
- Unnecessary images occupy the storage space on your server and increase the cost of your hosting.
- When the theme is changed all old images will not have correct thumbnails as per the new theme. This will force the original images to be served as it is and then resized according to the required size on sliders and widgets. Without the correct thumbnails the speed of your site will get drastically affected.
- The look of your site will get impacted when the required thumbnails are not available.
4. View Thumbnails Generated on Your Site
You can view all the uploaded media files from the menu “Media > Library” in your WordPress admin panel. But media library does not show the thumbnails generated on your site. So the of images in media library may lead to misunderstanding as it does not include thumbnail images. Below are some of the ways to check the number of images on your site. Number of thumbnails equals to total number of images minus the number you see in the media library.
- Use “File Count” option in “File Manager” to view directory wise files. This option may not be available in all hosts.
- Use FTP to check the numbers under “Uploads” folder. You may need to add number of files in different directory, especially if you have stored images month wise.
Generally thumbnails are shown with the image dimensions. For example, if your original image is “image.png” then the thumbnail name could be “image-65×65.png”. This indicates that your theme generates a image size of 65×65 pixels for each original image you upload.
If you can’t find the number of images then simply discuss with your hosting company to get the details.
5. How to Reduce WordPress Thumbnails?
5.1. Reducing Theme Thumbnails
As explained in the above example, most of the beautiful themes generate more than 10 thumbnails per image in order show it in sliders, widgets, related posts and as featured images. Once you decided to go for any particular theme check the number of thumbnails generated by uploading an image.
5.2. Reducing Plugin Thumbnails
Plugins also generate separate set of thumbnails especially slider and gallery plugins will generate huge number of thumbnails with various sizes. New set of thumbnails will get generated every time you try changing the dimensions. It is recommended to test these types of plugins on your local development server before install them on your live site.
6. Disabling Thumbnail Registration
Most of these image thumbs are used based on the type of layout you select in your theme. If you use uniform layout through out (which is the case with most of the sites and themes) your site then other images thumbs will never be used in your site. For example, your theme may offer related posts at bottom or left/right side and generate separate image thumbs. When you decided to go with bottom option the other thumbs still generated for left/right option will never be visible or used unless you switch the layout again. You need to unregister these unwanted thumbnails in order to avoid auto generation using one of the following options.
- Disable registration in functions.php file
- Disable default thumbnail generation in “Media” settings
6.1. Deregister Image Size in functions.php File
- Navigate to “Appearance > Editor” option in your WordPress admin panel.
- Locate functions.php file.
- Deactivate the thumbnail registrations, which you don’t need as shown in the example below:
- Save your changes.
Now try to upload an image and check the file count in your hosting account, you will not be seeing those unregistered image thumbs.
Similarly, you can unregister image thumbs in functions.php file of that particular plugin under “Plugins > Editor” section.
6.2. Stop Generating Default WordPress Thumbnails
Though you don’t use default WordPress theme, thumbnails will still be generated as per your medial settings. If you do not need WordPress to automatically generate normal, medium and large thumbs then make the dimensions as 0 under “Settings > Media”.
7. Deleting Unused Thumbnail Images
If your file count is already exceeded the limit set by the hosting provider, you can clean up your site with the two major activities.
- Delete all unused and unnecessary plugins, which generate thumbnails.
- Normally images are stored along with the size in your server. If you know what are the sizes you need it on your site, then delete all other sizes. This is an easy task of sorting and deleting based on size in your local PC or Mac if your site is not yet uploaded in live server. On a live site you can delete files from file manager option in your hosting account or using FTP software like FileZilla.
8. Deleting Thumbnails Using Free Plugins
You can cleanup the thumbnails either manually using FTP or using plugins. The FTP method will take large amount of time especially if you have organized your images under month and year folders. The plugin method is simple and will take considerably lesser time based on the number of images on your installation. There are many plugins available for this purpose and we will explain here with two ways.
- Using “Force Regenerate Thumbnails” plugin.
- Using”Thumbnail Cleaner” and “Regenerate Thumbnail” plugins.
8.1. Force Regenerate Thumbnails
This is a very straight forward way of cleaning up the thumbnails. Install and activate “Force Regenerate Thumbnails” plugin. This plugin will help you to delete all unused thumbnails and generate new thumbnails as per the new theme and setup. You can either regenerate on bulk or choose selected images from “Media > Library”.
The progress of the regeneration and the details for each image will be shown. You can clearly see how many thumbnails are deleted and how many are newly generated.
8.2. Using Thumbnail Cleaner and Regenerate Thumbnails Plugins
In this method you need two plugins to do the cleanup task. The advantage here is you will take the backup of all your images before the regeneration. You can use this backup for restoring purpose in case of any issues.
8.2.1. WordPress Thumbnail Cleaner Plugin
Install and activate the thumbnail cleaner plugin from your WordPress admin panel. It will create a new menu named “Thumbnail Cleaner” under “Tools” menu. Using the plugin is very simple with each available option is just a click of button.
1. Backup – As a standard process, before doing any irreversible action (like deleting thumbnails) you need to backup the content. You can do this with single click and the plugin will backup all your images and media files under “uploads” folder to a separate folder under “wp-content/backups/thumbnail-cleaner/”.
2. Analyze – Use this option to check how many thumbnail files can be deleted from your WordPress installation. This will be give you an estimation of how many files are generated compared to the actual number of media files you can see under “Media > Library”.
3. Clean Thumbnails – Once you decided to cleanup the thumbnails, click on this button to delete them.
4. Regenerate Thumbnails – We will explain this option in next section below.
5. Restore Backup – In case of any issue, you can just restore your “uploads” folder with the backup files.
8.2.2. Regenerate Thumbnails
Once you deleted all thumbnail, the look of your site may change since the images will be served from the original size (by resizing) instead of the thumbnails. The reason is simple since the actual thumbnails used by your current theme are also deleted when using the “Thumbnail Cleaner” plugin. The solution to bring the site back to shape is to regenerate images to create only required thumbnails for your site.
The fourth option”Regenerate Thumbnails” with “Thumbnail Cleaner” plugin is for this purpose and you need a separate plugin for this. Navigate to “Plugins > Add New” section and look for the “Regenerate Thumbnails” plugin.
Install the plugin from Alex Mills with over 1+ million active installs and activate it. Then navigate to “Tools > Regen. Thumbnails” section and regenerate all the images on your site. The process may take long time depending on the number of images on your site.
Clear the cache and check your site, it should come back to normal shape. Now your WordPress site will only have the required thumbnails which you can check by clicking on the “Start Analyzing” button from “Thumbnail Cleaner” plugin.
9. Caution for Regenerating Thumbnails
Regenerating thumbnails of each image is a resource intensive process, so be aware of the followings:
- This will shoot up the CPU consumption of your hosting server.
- If you have large number of images then we recommend to run the regeneration process from media library by selecting page by page (that is 20 images per execution).
- If you are running a site on shared hosting server, you may end up in account banning for exceeding the CPU / execution limit. So run the regeneration on limited images or discuss with your hosting company if they can help to increase the resources for you.
- The live site will be slow during regeneration, hence run the regeneration when there is less traffic on your site.
- When you have image optimization plugins like WP Smush with the “optimize images on upload” option is enabled, regeneration will also call the optimization process and result in heavy consumption of server resources. So you can disable image optimization plugins and then optimize the images later or run regeneration on limited number of images on batch.