WooCommerce::add_image_sizes()publicWC 2.3

Add WC Image sizes to WP.

As of 3.3, image sizes can be registered via themes using add_theme_support for woocommerce and defining an array of args. If these are not defined, we will use defaults. This is handled in wc_get_image_size function.

3.3 sizes:

woocommerce_thumbnail - Used in product listings. We assume these work for a 3 column grid layout. woocommerce_single - Used on single product pages for the main image.

{} It's a method of the class: WooCommerce{}

No Hooks.


null. Nothing.


$WooCommerce = new WooCommerce();


Since 2.3 Introduced.

Code of WooCommerce::add_image_sizes() WC 6.5.1

public function add_image_sizes() {
	$thumbnail         = wc_get_image_size( 'thumbnail' );
	$single            = wc_get_image_size( 'single' );
	$gallery_thumbnail = wc_get_image_size( 'gallery_thumbnail' );

	add_image_size( 'woocommerce_thumbnail', $thumbnail['width'], $thumbnail['height'], $thumbnail['crop'] );
	add_image_size( 'woocommerce_single', $single['width'], $single['height'], $single['crop'] );
	add_image_size( 'woocommerce_gallery_thumbnail', $gallery_thumbnail['width'], $gallery_thumbnail['height'], $gallery_thumbnail['crop'] );

	 * Legacy image sizes.
	 * @deprecated 3.3.0 These sizes will be removed in 4.6.0.
	add_image_size( 'shop_catalog', $thumbnail['width'], $thumbnail['height'], $thumbnail['crop'] );
	add_image_size( 'shop_single', $single['width'], $single['height'], $single['crop'] );
	add_image_size( 'shop_thumbnail', $gallery_thumbnail['width'], $gallery_thumbnail['height'], $gallery_thumbnail['crop'] );