- This topic has 7 replies, 2 voices, and was last updated 2 years, 12 months ago by
David.
-
AuthorPosts
-
March 20, 2023 at 5:04 am #2573976
Pamilab Srl
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,
MikeMarch 20, 2023 at 6:59 am #2574100David
StaffCustomer SupportHi 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 );March 20, 2023 at 8:55 am #2574363Pamilab Srl
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,
MikeMarch 20, 2023 at 9:43 am #2574459David
StaffCustomer SupportCan i see the site ?
March 20, 2023 at 10:03 am #2574498Pamilab Srl
Yes! This is the staging website.
I already added your snippet.
Thank you,
MikeMarch 21, 2023 at 12:54 am #2575108David
StaffCustomer SupportIs it just that one product ?
March 22, 2023 at 11:30 am #2577416Pamilab Srl
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,
MMarch 23, 2023 at 5:47 am #2578623David
StaffCustomer SupportGlad to be of help
-
AuthorPosts
- You must be logged in to reply to this topic.