Hi, I hope you’re doing well.
The product photo size is fully adjusted,
but when hovering, the second image that appears
doesn’t have good quality.
Thanks.
This topic has 4 replies, 2 voices, and was last updated 1 days, 3 hours ago ago by Samir Malik
Hi, I hope you’re doing well.
The product photo size is fully adjusted,
but when hovering, the second image that appears
doesn’t have good quality.
Thanks.
Hello MAHDAR,
We have resolved this issue by adding the following custom code to the functions.php file located in your child theme:
// Add this to your functions.php file
add_filter( 'wp_get_attachment_image_attributes', 'change_hover_swap_image_size', 10, 3 );
function change_hover_swap_image_size( $attr, $attachment, $size ) {
// Check if it's the woocommerce_thumbnail size (the one used in hover swap)
if ( $size === 'woocommerce_thumbnail' ) {
// Get the full size image data
$image_src = wp_get_attachment_image_src( $attachment->ID, 'full' );
if ( $image_src ) {
$attr['src'] = $image_src[0];
$attr['width'] = $image_src[1];
$attr['height'] = $image_src[2];
$attr['srcset'] = wp_get_attachment_image_srcset( $attachment->ID, 'full' );
$attr['sizes'] = wp_get_attachment_image_sizes( $attachment->ID, 'full' );
}
}
return $attr;
}
Could you please review it and confirm that everything is working correctly?
Best regards,
8Theme Team
Thank you.
But it gives this error:
There was a critical error on your website.
Hello, MAHDAR,
We have already added that code, so there is no need for you to add it again.
Best regards,
The 8Theme Team
You must be logged in to reply to this topic.Log in/Sign up