1. Install the plugin https://wordpress.org/plugins/regenerate-thumbnails/
2. After installing the plugin, check which images are being generated here:
3. Check which images you don’t need to generate. And create a function from them (add it to the functions.php file of your theme).
4. Function code to disable image generation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
//disable generation of all default image sizes start function remove_all_images($sizes){ unset($sizes['medium']); unset( $sizes[ 'medium_large' ]); unset( $sizes[ 'large' ]); //Woocommerce unset( $sizes[ 'woocommerce_single' ]); unset( $sizes[ 'woocommerce_gallery_thumbnail' ]); unset( $sizes[ 'shop_thumbnail' ]); // Remove Shop thumbnail (180 x 180 hard cropped) unset( $sizes[ 'shop_catalog' ]); // Remove Shop catalog (300 x 300 hard cropped) unset( $sizes[ 'shop_single' ]); // Shop single (600 x 600 hard cropped) return $sizes; } add_filter('intermediate_image_sizes_advanced', 'remove_all_images'); |
Where, for example, unset( $sizes[ ‘large’ ]); – replace ‘large’ with the name of your image sizes (taken from the plugin).
Once you’ve created this list and saved it in your theme’s file, the image sizes you’ve listed will no longer be generated. But the question arises – what about the existing images?
How to clean up your media folder from unnecessary generated images?
For example, if you have an online store with even a hundred products, and each product has several images, which are duplicated 10 times, your site size is already significant. What to do?
- Create a site backup.
In our plugin, check the box – free up disk space by deleting old unregistered thumbnail sizes. This may cause image loading errors on post pages.
Click – regenerate thumbnails for all 28 attachments.
Learn more about how to disable thumbnail generation:
Leave a Reply