iamdharmesh / featured-image-by-url

This plugin allows to use an external URL Images as Featured Image for your post, page & custom post types like WooCommerce Product. Includes support for Product Gallery (WooCommerce).
https://wordpress.org/plugins/featured-image-by-url/
GNU General Public License v2.0
34 stars 12 forks source link

Get Hover image for WooCommerce Grid in Flatsome theme is not working #47

Open nhtera opened 3 years ago

nhtera commented 3 years ago

Describe the bug

So, does anyone has a solution for this issue? Can I override this function to get the feature display second image working?


function flatsome_woocommerce_get_alt_product_thumbnail() {
        $hover_style = get_theme_mod( 'product_hover', 'fade_in_back' );
        if ( $hover_style !== 'fade_in_back' && $hover_style !== 'zoom_in' ) {
            return;
        }

        global $product;
        $attachment_ids = $product->get_gallery_image_ids();
        $class          = 'show-on-hover absolute fill hide-for-small back-image';
        if ( $hover_style == 'zoom_in' ) {
            $class .= $class . ' hover-zoom';
        }

        if ( $attachment_ids ) {
            $loop = 0;
            foreach ( $attachment_ids as $attachment_id ) {
                $image_link = wp_get_attachment_url( $attachment_id );
                if ( ! $image_link ) {
                    continue;
                }
                $loop ++;
                echo apply_filters( 'flatsome_woocommerce_get_alt_product_thumbnail',
                    wp_get_attachment_image( $attachment_id, 'woocommerce_thumbnail', false, array( 'class' => $class ) ) );
                if ( $loop == 1 ) {
                    break;
                }
            }
        }
    }

Environment (please complete the following information):

Plugin Version 1.1.7 WordPress Version 5.8.0 WooCommerce Version 5.6.0 Flatsome Version 3.14.2