diff --git a/plugins/woocommerce-blocks/src/BlockTypes/ProductGalleryLargeImage.php b/plugins/woocommerce-blocks/src/BlockTypes/ProductGalleryLargeImage.php index ca5728d9971..21ff7ce8932 100644 --- a/plugins/woocommerce-blocks/src/BlockTypes/ProductGalleryLargeImage.php +++ b/plugins/woocommerce-blocks/src/BlockTypes/ProductGalleryLargeImage.php @@ -132,7 +132,8 @@ class ProductGalleryLargeImage extends AbstractBlock { $main_images = ProductGalleryUtils::get_product_gallery_images( $product_id, 'full', - $attributes + $attributes, + 'wc-block-woocommerce-product-gallery-large-image__container' ); $visible_main_image = array_shift( $main_images ); diff --git a/plugins/woocommerce-blocks/src/BlockTypes/ProductGalleryThumbnails.php b/plugins/woocommerce-blocks/src/BlockTypes/ProductGalleryThumbnails.php index 439871b5d2b..be083c13290 100644 --- a/plugins/woocommerce-blocks/src/BlockTypes/ProductGalleryThumbnails.php +++ b/plugins/woocommerce-blocks/src/BlockTypes/ProductGalleryThumbnails.php @@ -63,7 +63,7 @@ class ProductGalleryThumbnails extends AbstractBlock { if ( $product ) { $post_thumbnail_id = $product->get_image_id(); - $product_gallery_images = ProductGalleryUtils::get_product_gallery_images( $post_id, 'thumbnail', array() ); + $product_gallery_images = ProductGalleryUtils::get_product_gallery_images( $post_id, 'thumbnail', array(), 'wc-block-product-gallery-thumbnails__thumbnail' ); if ( $product_gallery_images && $post_thumbnail_id ) { $html = ''; $number_of_thumbnails = isset( $block->context['thumbnailsNumberOfThumbnails'] ) ? $block->context['thumbnailsNumberOfThumbnails'] : 3; @@ -74,11 +74,9 @@ class ProductGalleryThumbnails extends AbstractBlock { break; } - $html .= ''; - $thumbnails_count++; } diff --git a/plugins/woocommerce-blocks/src/Utils/ProductGalleryUtils.php b/plugins/woocommerce-blocks/src/Utils/ProductGalleryUtils.php index 13f136d688f..68b739a45d4 100644 --- a/plugins/woocommerce-blocks/src/Utils/ProductGalleryUtils.php +++ b/plugins/woocommerce-blocks/src/Utils/ProductGalleryUtils.php @@ -17,9 +17,10 @@ class ProductGalleryUtils { * @param int $post_id Post ID. * @param string $size Image size. * @param array $attributes Attributes. + * @param string $wrapper_class Wrapper class. * @return array */ - public static function get_product_gallery_images( $post_id, $size = 'full', $attributes = array() ) { + public static function get_product_gallery_images( $post_id, $size = 'full', $attributes = array(), $wrapper_class = '' ) { $product_gallery_images = array(); $product = wc_get_product( $post_id ); @@ -35,7 +36,10 @@ class ProductGalleryUtils { $attributes ); - $product_image_html = ''; + if ( $wrapper_class ) { + $product_image_html = '
' . $product_image_html . '
'; + } + $product_image_html_processor = new \WP_HTML_Tag_Processor( $product_image_html ); $product_image_html_processor->next_tag( 'img' ); $product_image_html_processor->set_attribute(