1

Woocommerce upload media creates 7 additional image sizes. I use storefront theme.

When I upload image I would like Woocommerce creates just one image size which will be using for Catalog Images, Single Product Image and Product Thumbnails.

Is there any way to do it?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
adrian
  • 23
  • 2

1 Answers1

1

This is too complicated and not necessary as for example:

  • Wordpress media library uses Wordpress thumbnail size,
  • Wordpress blog and pages use some other Wordpress sizes,
  • WooCommerce need its 3 image own sizes and to use just one will oblige you to override a lot of different Woocommerce templates (and will create problems in some core functions).

Also remember that for the different screen devices, different image sizes are used too. This make shorter loading time on medium and small devices.

Now you can use the code below to remove images sizes if you want to try and test (you should comment the image sizes you want to keep):

add_action('init', 'remove_plugin_image_sizes');
function remove_plugin_image_sizes() {
    # remove_image_size('thumbnail'); // Wordpress (used by the media librairy to display thumbs)
    remove_image_size('medium'); // Wordpress
    remove_image_size('medium_large'); // Wordpress
    remove_image_size('large'); // Wordpress
    remove_image_size('shop_thumbnail'); // Woocommerce
    remove_image_size('shop_catalog'); // Woocommerce
    remove_image_size('shop_single'); // Woocommerce
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

I don't guaranty anything for WooCommerce as this is untested and the different image sizes are used in templates and functions, so you can have real problems.

You will have always the full size image (the original upload).

ACTIVATION:
You will need to switch your active theme to another and then switch back to activate it.


If it's a problem of weight, you can set small sizes for unused sizes in:

  • Wordpress general settings > Media librairy
  • Woocommerce settings > Products > Display

You should need to regenerate all existing images with Regenerate Thumbnails plugin

You can use also automated compression image tools like Smush Image Compression and Optimization plugin


Related answer: Disable original image crop in WooCommerce

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • I putted remove_image_size in functions.php but it not working – adrian Dec 24 '17 at 18:41
  • @adrian You should need to make a DB backup first.Then should need to switch to the default Wordpress theme and to switch back to your actual theme, to enable this… – LoicTheAztec Dec 26 '17 at 00:44