diff --git a/includes/class-woocommerce.php b/includes/class-woocommerce.php index a07a42210ad..f4a3bcb5c45 100644 --- a/includes/class-woocommerce.php +++ b/includes/class-woocommerce.php @@ -539,11 +539,13 @@ final class WooCommerce { * @since 2.3 */ public function add_image_sizes() { - $thumbnail = wc_get_image_size( 'thumbnail' ); - $single = wc_get_image_size( 'single' ); + $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'] ); // 2x thumbnail size for retina, and when showing less columns. add_image_size( 'woocommerce_thumbnail_2x', $thumbnail['width'] * 2, '' !== $thumbnail['height'] ? $thumbnail['height'] * 2 : '', $thumbnail['crop'] ); diff --git a/includes/customizer/class-wc-shop-customizer.php b/includes/customizer/class-wc-shop-customizer.php index 6631483934e..31c5351ced2 100644 --- a/includes/customizer/class-wc-shop-customizer.php +++ b/includes/customizer/class-wc-shop-customizer.php @@ -156,7 +156,7 @@ class WC_Shop_Customizer { setting.bind( function( value ) { var min = parseInt( '', 10 ); var max = parseInt( '', 10 ); - + value = parseInt( value, 10 ); if ( max && value > max ) { @@ -496,7 +496,7 @@ class WC_Shop_Customizer { 'woocommerce_thumbnail_image_width', array( 'label' => __( 'Thumbnail width', 'woocommerce' ), - 'description' => __( 'Image size used for products in the catalog and product gallery thumbnails.', 'woocommerce' ), + 'description' => __( 'Image size used for products in the catalog.', 'woocommerce' ), 'section' => 'woocommerce_product_images', 'settings' => 'woocommerce_thumbnail_image_width', 'type' => 'number', diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 32e377518af..d118cdec82d 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -722,6 +722,13 @@ function wc_get_image_size( $image_size ) { 'crop' => 1, ); + // Size mapping. + if ( in_array( $image_size, array( 'shop_single', 'woocommerce_single' ), true ) ) { + $image_size = 'single'; + } elseif ( in_array( $image_size, array( 'shop_thumbnail', 'shop_catalog', 'woocommerce_thumbnail' ), true ) ) { + $image_size = 'thumbnail'; + } + if ( is_array( $image_size ) ) { $size = array( 'width' => isset( $image_size[0] ) ? absint( $image_size[0] ) : 600, @@ -729,12 +736,18 @@ function wc_get_image_size( $image_size ) { 'crop' => isset( $image_size[2] ) ? absint( $image_size[2] ) : 1, ); $image_size = $size['width'] . '_' . $size['height']; - } elseif ( in_array( $image_size, array( 'single', 'shop_single', 'woocommerce_single' ), true ) ) { + + } elseif ( 'single' === $image_size ) { $size['width'] = absint( wc_get_theme_support( 'single_image_width', get_option( 'woocommerce_single_image_width', 600 ) ) ); $size['height'] = ''; $size['crop'] = 0; - $image_size = 'single'; - } elseif ( in_array( $image_size, array( 'thumbnail', 'shop_thumbnail', 'shop_catalog', 'woocommerce_thumbnail' ), true ) ) { + + } elseif ( 'gallery_thumbnail' === $image_size ) { + $size['width'] = absint( wc_get_theme_support( 'gallery_thumbnail_image_width', 100 ) ); + $size['height'] = $size['width']; + $size['crop'] = 1; + + } elseif ( 'thumbnail' === $image_size ) { $size['width'] = absint( wc_get_theme_support( 'thumbnail_image_width', get_option( 'woocommerce_thumbnail_image_width', 300 ) ) ); $cropping = get_option( 'woocommerce_thumbnail_cropping', '1:1' ); @@ -753,7 +766,6 @@ function wc_get_image_size( $image_size ) { $size['height'] = round( ( $size['width'] / $width ) * $height ); $size['crop'] = 1; } - $image_size = 'thumbnail'; } return apply_filters( 'woocommerce_get_image_size_' . $image_size, $size );