Archived topic
Remove featured image
7 replies · Started by Pamilab Srl on March 20, 2023
Hi everyone,
I found a partial solution to a my issue: https://generatepress.com/forums/topic/remove-featured-image-in-product-when-a-product-gallery-is-present/
But there is a problem on the navigation gallery. The first image preview is the featured image (only image, the navigation is ok) and not the first image of the gallery.
How I can resolve it?
Or is it possibile display of the default the second image (so the first image of the gallery) and leave the featured image? Because this solution for me it's OK!
My goal: I don't want to have the featured image right away when the customers load the product page.
Thank you,
Mike
Hi there,
does this snippet work:
function woocommerce_single_product_image_thumbnail_html( $html, $attachment_id ) {
global $product;
$attachment_ids = $product->get_gallery_image_ids();
return ( $attachment_ids && $product->get_image_id() == $attachment_id ) ? '' : $html;
}
add_filter( 'woocommerce_single_product_image_thumbnail_html', 'woocommerce_single_product_image_thumbnail_html', 99, 2 );
Hi David,
It doesn't work completely. On the first position of the navigation gallery preview there is the featured image and not the first image of the gallery.
<ol class="flex-control-nav flex-control-thumbs"><li><img onload="this.width = this.naturalWidth; this.height = this.naturalHeight" src="https://www.staging14.pluto.pippo/wp-content/uploads/2022/12/1-100x100.jpg" alt="prod-1" class="flex-active" draggable="false" data-o_src="https://www.staging14.pluto.pippo/wp-content/uploads/2022/12/1-100x100.jpg" width="100" height="100"></li><li><img onload="this.width = this.naturalWidth; this.height = this.naturalHeight" src="https://www.staging14.pluto.pippo/wp-content/uploads/2022/12/2-100x100.jpg" alt="prod-2" draggable="false" width="100" height="100"></li><li><img onload="this.width = this.naturalWidth; this.height = this.naturalHeight" src="https://www.staging14.pluto.pippo/wp-content/uploads/2021/02/3-100x100.jpg" alt="prod-3" draggable="false" width="100" height="100"></li></ol>
The image in first "li" is wrong. It take the featured image preview.
Thank you,
Mike
Can i see the site ?
Yes! This is the staging website.
I already added your snippet.
Thank you,
Mike
Is it just that one product ?
Hi David,
In production everything ok! So the issue is only on staging site. I don't know.. it's strange because it is a copy of production.
But nothing! :)
Thank you for support,
M
Glad to be of help