[Resolved] Disable lightbox woocommerce, but retain zoom on hover

Home Forums Support [Resolved] Disable lightbox woocommerce, but retain zoom on hover

Home Forums Support Disable lightbox woocommerce, but retain zoom on hover

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1617545
    Pauline

    Hello

    I would like to disable the lightbox for individual product images in woocommerce, but still retain the zoom on hover. Can you advise me how to do this (preferably just using CSS – I’ve never delved into PHP, but if it’s necessary, I’ll give it a go…)?

    Thanks
    Pauline

    #1617709
    Ying
    Staff
    Customer Support

    Hi Pauline,

    There’re 2 options, CSS and PHP πŸ™‚

    Here’s the CSS solution:

    .single-product a.woocommerce-product-gallery__trigger, .single-product img.zoomImg {
        display: none !important;
    }

    And here’s PHP solution:

    function remove_image_zoom_support() {
        remove_theme_support( 'wc-product-gallery-zoom' );
        remove_theme_support( 'wc-product-gallery-lightbox' );
    }
    add_action( 'wp', 'remove_image_zoom_support', 100 );

    Let me know πŸ™‚

    #1618160
    Pauline

    Hi Ying

    Thanks so much for giving me 2 options πŸ™‚ I used the CSS, but it took away the “zoom/magnification on hover”. Perhaps I did not phrase my question correctly – I would like the user to be able to zoom/magnify over the image when they glide their mouse over the image (this is the default woocommerce capability which I am getting on my website), but I don’t want them to be able to click on the picture and have it open full size in another screen. Is there any CSS that can do this?

    Best regards
    Pauline

    #1618333
    David
    Staff
    Customer Support

    Hi there,

    the PHP solution that Ying provided disables both the zoom and the lightbox, so you just need to remove the lightbox like so:

    function remove_image_zoom_support() {
        remove_theme_support( 'wc-product-gallery-lightbox' );
    }
    add_action( 'wp', 'remove_image_zoom_support', 100 );
    #1618808
    Pauline

    Thankyou David for sorting me out again – the PHP worked perfectly πŸ™‚ Thanks also to Ying for her earlier code suggestions, which I will reference for the future πŸ™‚

    #1619654
    David
    Staff
    Customer Support

    Glad we could be of help

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.