The second image had no quality. - by MAHDAR

This topic has 4 replies, 2 voices, and was last updated 1 month, 4 weeks ago ago by Samir Malik

  • Avatar: mahdar
    MAHDAR
    Participant
    December 2, 2025 at 03:18

    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.

    Please, contact administrator
    for this information.
    3 Answers
    Avatar: Samir Malik
    Samir Malik
    Support staff
    December 2, 2025 at 03:57

    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

    Avatar: mahdar
    MAHDAR
    Participant
    December 2, 2025 at 10:41

    Thank you.
    But it gives this error:
    There was a critical error on your website.

    Avatar: Samir Malik
    Samir Malik
    Support staff
    December 2, 2025 at 12:21

    Hello, MAHDAR,

    We have already added that code, so there is no need for you to add it again.

    Best regards,
    The 8Theme Team

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.