3
votes

Every time i upload a new image to the wordpress media library, wordpress generates 3 versions of the image with different sizes and Woocommerce also generates another 3 images.

I dont need 6 versions of the same image on my website. The 3 sizes generated by wordpress are enough.

My website contains alot of images, and i want to minimize the disk space on my server by preventing woocommerce from generating new unnecessary images.

I could not find any solution online.

Any ideas How to accomplish this?

1

1 Answers

1
votes

You are right that woocommerce creates image sizes based on default WordPress sizes. But I won't recommend you to remove them because woocommerce expects these sizes and does not handle their absence ( does not revert to using default sizes ). So if you remove these sizes, you also have to write more code to adjust woocommerce for using default image sizes.

Now if you understand all this and still wish to do it. You can remove the woocommerce images sizes by using this snippet in functions.php or in a plugin.

function sr_remove_woocommerce_image_sizes() {
    
    // Remove woocommerce copied sizes from default
    remove_image_size( 'woocommerce_thumbnail' );
    remove_image_size( 'woocommerce_single' );
    remove_image_size( 'woocommerce_gallery_thumbnail' );
    
}
add_action( 'init', 'sr_remove_woocommerce_image_sizes', 99 );

Note: This won't delete all the existing image sizes, it will just stop creating them moving forward.