How to manage too many thumbnails generated by wordpress

Posted on

How to manage too many thumbnails generated by wordpress

Thumbnail, medium, and big size images are generated by default when you upload a picture to WordPress. To manage the efficiency of your site or for design reasons, you might occasionally want to employ custom WordPress image sizes. WordPress’s automatic picture compression is designed to be a convenience, however it may wind up producing too many files that use needless storage space and result in excessively large backups.

Managing WordPress from generating various picture sizes is advantageous because of this. You can configure your WordPress core to stop cropping or to only crop the picture sizes you need if you’re trying to save space or simply aren’t using all of the different image sizes that are being made. You should at least be able to find the three picture sizes produced by WordPress. If there are more than three, your WordPress theme’s copies are probably responsible. Open the file function.php in your theme directory and search for any lines of code that resemble this one: add_image_size. Also, keep an eye out for any that contain the phrase "set_thumbnail_post_size". Save your modifications after deleting these lines.

Using plugins that additionally make copies of your photos can result in unnecessary huge backups and a reduction in available disk space. Fortunately, by setting the default picture sizes to zero in your media settings, you can prevent WordPress from performing this action. Open your WordPress admin dashboard and go to Settings > Media. If you assume that all of the picture size settings are ones you won’t be utilizing, adjust them all to 0 and then save the changes.

Finally, by including a filter, you can stop WordPress from compressing your photographs. You may easily add the following line of code to your theme’s functions.php file to prevent WordPress from compressing and cropping images:

add_filter('jpeg_quality', function($arg){return 100;});
add_filter( 'wp_editor_set_quality', function($arg){return 100;} );

apply_filters(‘wp_editor_set_quality’) is found 1 times: /wp-includes/class-wp-image-editor.php line 260. 256. 257. 258. 259. 260. 261. 262. 263. Avoid high-quality TIFF files when saving your photograph because the size increases significantly. Instead, stick to JPEGs for photographs and PNGs for logos and graphics. Although JPEGs somewhat lower image quality, the difference is undetectable on the web and your image will load more quickly.


Here's a comprehensive approach to streamline the process:

  1. Audit Existing Thumbnails: Start by evaluating which thumbnails are essential and which ones can be eliminated. You can use plugins like "Regenerate Thumbnails" to regenerate thumbnails only for the necessary sizes.

  2. Limit Thumbnail Sizes: Reduce the number of thumbnail sizes generated by WordPress. You can do this by modifying the functions.php file in your theme or using a plugin like "Simple Image Sizes" to control thumbnail dimensions.

  3. Optimize Image Sizes: Before uploading images, optimize them for the web to reduce file size. This will help in faster loading times and less storage space consumption.

  4. Use Lazy Loading: Implement lazy loading for images so that thumbnails are loaded only when they come into view, reducing the initial page load time.

  5. Cache Thumbnails: Utilize caching plugins like WP Rocket or W3 Total Cache to cache thumbnails and improve website performance.

  6. Cleanup Unused Thumbnails: Regularly clean up unused thumbnails using plugins like "Media Cleaner" or "WP-Optimize" to remove unnecessary files and free up storage space.

  7. Consider CDN: Use a Content Delivery Network (CDN) to deliver images efficiently, reducing server load and improving performance globally.

  8. Optimize Database: Optimize your WordPress database regularly to remove redundant data, including unused thumbnails.

  9. Monitor Performance: Keep an eye on your website's performance metrics using tools like Google PageSpeed Insights or GTmetrix and make adjustments accordingly.

By implementing these strategies, you can effectively manage and optimize the generation of thumbnails in WordPress, ensuring better performance and smoother user experience.

Was this helpful?

Thanks for your feedback!