WooCommerce::add_image_sizes()
Add WC Image sizes to WP.
Description Description
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.
Source Source
File: includes/class-woocommerce.php
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 These sizes will be removed in 4.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'] ); }
Changelog Changelog
Version | Description |
---|---|
2.3 | Introduced. |