Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nhtera opened this issue Aug 23, 2021 · 0 comments
Open
Labels
bug Something isn't working

Comments

@nhtera
Copy link

nhtera commented Aug 23, 2021

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

@nhtera nhtera added the bug Something isn't working label Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant