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.

Метод класса: WooCommerce{}

Хуков нет.


null. Ничего (null).


$WooCommerce = new WooCommerce();

Список изменений

С версии 2.3 Введена.

Код WooCommerce::add_image_sizes() WC 8.9.0

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'] );