From db3270a390b056b40767dc53e2f396f640814000 Mon Sep 17 00:00:00 2001 From: pierrebuet Date: Fri, 21 Sep 2018 19:33:04 +0200 Subject: [PATCH] Show the right size of placeholder image on single product page in the template for the product image, wc_placeholder_img_src() returns the thumbnail size of the image. In order to use 'woocommerce_single' as size, the function needs to be corrected, so the function use the size and not a calculated array of sizes. wc_get_image_size doesn't return an height for the woocommerce_single size. Further and since the image sizes are declared, there is no need to translate the size to an array. --- includes/wc-product-functions.php | 3 +-- templates/single-product/product-image.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/includes/wc-product-functions.php b/includes/wc-product-functions.php index c9b1119de16..6b2249ae391 100644 --- a/includes/wc-product-functions.php +++ b/includes/wc-product-functions.php @@ -284,8 +284,7 @@ function wc_placeholder_img_src( $size = 'woocommerce_thumbnail' ) { if ( ! empty( $placeholder_image ) ) { if ( is_numeric( $placeholder_image ) ) { - $dimensions = wc_get_image_size( $size ); - $image = wp_get_attachment_image_src( $placeholder_image, array( $dimensions['width'], $dimensions['height'] ) ); + $image = wp_get_attachment_image_src( $placeholder_image, $size ); if ( ! empty( $image[0] ) ) { $src = $image[0]; diff --git a/templates/single-product/product-image.php b/templates/single-product/product-image.php index f410108fc8b..00dd8af94ab 100644 --- a/templates/single-product/product-image.php +++ b/templates/single-product/product-image.php @@ -13,7 +13,7 @@ * @see https://docs.woocommerce.com/document/template-structure/ * @author WooThemes * @package WooCommerce/Templates - * @version 3.3.2 + * @version 3.5.0 */ defined( 'ABSPATH' ) || exit; @@ -41,7 +41,7 @@ $wrapper_classes = apply_filters( 'woocommerce_single_product_image_gallery_cl $html = wc_get_gallery_image_html( $post_thumbnail_id, true ); } else { $html = ''; }