Site logo

[Resolved] Remove featured image

Home Forums Support [Resolved] Remove featured image

Home Forums Support Remove featured image

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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,
    Mike

    #2574100
    David
    Staff
    Customer Support

    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 );
    #2574363
    Pamilab 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,
    Mike

    #2574459
    David
    Staff
    Customer Support

    Can i see the site ?

    #2574498
    Pamilab Srl

    Yes! This is the staging website.

    I already added your snippet.

    Thank you,
    Mike

    #2575108
    David
    Staff
    Customer Support

    Is it just that one product ?

    #2577416
    Pamilab 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,
    M

    #2578623
    David
    Staff
    Customer Support

    Glad to be of help

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.