From e037635f184fe5ea586e5a0928162af21ea659ba Mon Sep 17 00:00:00 2001 From: AJ Clarke Date: Fri, 14 Apr 2017 09:52:13 -0700 Subject: [PATCH] Prevents duplicate thumbnail when featured image is added to the product gallery --- templates/single-product/product-thumbnails.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/templates/single-product/product-thumbnails.php b/templates/single-product/product-thumbnails.php index 67e15ec6ba8..b9ca4b0c709 100644 --- a/templates/single-product/product-thumbnails.php +++ b/templates/single-product/product-thumbnails.php @@ -25,7 +25,13 @@ global $post, $product; $attachment_ids = $product->get_gallery_image_ids(); if ( $attachment_ids && has_post_thumbnail() ) { + foreach ( $attachment_ids as $attachment_id ) { + + if ( get_post_thumbnail_id() == $attachment_id ) { + continue; + } + $full_size_image = wp_get_attachment_image_src( $attachment_id, 'full' ); $thumbnail = wp_get_attachment_image_src( $attachment_id, 'shop_thumbnail' ); $image_title = get_post_field( 'post_excerpt', $attachment_id ); @@ -43,5 +49,7 @@ if ( $attachment_ids && has_post_thumbnail() ) { $html .= ''; echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $attachment_id ); + } + }