featured-image-by-url
featured-image-by-url copied to clipboard
Get Hover image for WooCommerce Grid in Flatsome theme is not working
Describe the bug
- I'm using a Flatsome theme. It has a feature to display a second product image when the mouse hover.
- I've tried to debug the function in the Flatsome theme. It's will get gallery Ids and get an attachment URL to display the second product image. When using this plugin it's can't get the second image in gallery because function wp_get_attachment_url from a fake attachment id.
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