WooCommerce: Disable Zoom, Slider & Lightbox @ Single Product

Sometimes, cool things don’t apply to certain businesses. Also, keeping the default WooCommerce behaviour might slow down your website, should you not need to use a specific functionality.

For example, I’m talking about the new “Featured Image Zoom”, introduced by WooCommerce a while ago. What if your customers don’t need this? How can you disable it?

Well, as usual, this can be done with a few PHP lines! Now go and disable all the stuff you don’t need ๐Ÿ™‚

Disable zoom, gallery and lightbox @ WooCommerce Single Product Page

PHP Snippet [Approach #1]: Disable Zoom, Product Gallery Slider and Lightbox @ WooCommerce Single Product Page

/**
 * @snippet       Remove Zoom, Gallery @ Single Product Page
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @testedwith    WooCommerce 10
 * @community     https://businessbloomer.com/club/
 */
 
add_action( 'after_setup_theme', 'bbloomer_remove_zoom_lightbox_theme_support', 9999 );
 
function bbloomer_remove_zoom_lightbox_theme_support() { 
    remove_theme_support( 'wc-product-gallery-zoom' );
    remove_theme_support( 'wc-product-gallery-lightbox' );
    remove_theme_support( 'wc-product-gallery-slider' );
}

PHP Snippet [Approach #2]: Disable Zoom, Product Gallery Slider and Lightbox @ WooCommerce Single Product Page

If you’re on a custom theme, and this theme doesn’t declare “support” for the enhanced gallery, code above may not work. Thankfully WooCommerce comes also with handy filters within the WC_Frontend_Scripts class, that you can use to globally disable zoom, swipe and flexslider.

/**
 * @snippet       Remove Zoom, Gallery @ Single Product Page
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @testedwith    WooCommerce 10
 * @community     https://businessbloomer.com/club/
 */
 
add_filter( 'woocommerce_single_product_zoom_enabled', '__return_false' );
add_filter( 'woocommerce_single_product_photoswipe_enabled', '__return_false' );
add_filter( 'woocommerce_single_product_flexslider_enabled', '__return_false' );

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

31 thoughts on “WooCommerce: Disable Zoom, Slider & Lightbox @ Single Product

  1. Since WC 10 the good ‘ol remove_theme_support doesn’t seem to do it anymore.

    Nowe i need to do:

    /**
    * Disable WooCommerce product image zoom (WC 10+ compatibility).
    * Uses higher priority to override WooCommerce’s __return_true filter.
    */
    add_filter(‘woocommerce_single_product_zoom_enabled’, ‘__return_false’, 20);

    1. Thank you Gustav. Code works perfectly for me on this same website for example. So it’s not a WC problem, but maybe a theme-specific problem. Your code works as well indeed, so I will edit the post and add this as a second solution. Thank you!

  2. What’s interesting now is that this isn’t supporting all 3. It’s either one or the other. In my tests anyway.

    1. Sorry, not sure I follow. Could you please expand on that?

  3. Alas, neither your solution nor Anne’s above are working for me on WooCommerce 4.3.3 (Twenty Twenty theme).

    And the big one that should also be considered for removal because it loads 4 files is photoswipe.

    Thanks!

    1. Tried on a different theme already?

  4. One and only reliable place you get good snippets ๐Ÿ™‚

    1. Cheers!

  5. If you have an unsupported theme this code doesn’t work – I used a snippet I found here:

    https://github.com/woocommerce/woocommerce/issues/18131

    // disable the magnification zoom in product images
    add_action( 'template_redirect', function() {
        remove_theme_support( 'wc-product-gallery-zoom' );
        remove_theme_support( 'wc-product-gallery-lightbox' );
        remove_theme_support( 'wc-product-gallery-slider' );
    }, 100 );
    
    1. Thank you Anne

    2. OMG!! Anne! This is the only thing that worked for me! I’ve seen the solution above all over the internet and it’s working for some but not for many. I’m using WooCommerce on a custom them and this might explain why the code above didn’t work, but yours did! Much Gratitude!!

      1. Well done again Anne!

  6. Hi,

    I tried this snippet with the theme “Nirvana” (child theme), Woocommerce 3.6.4 and it doens’t work…

    Not sure why, but it’s too bad, it would have been exactly what I needed..

    Thank you anyway !

    1. No prob! Does it work if you switch to 2017 temporarily? If yes, ask Nirvana support team as they’re overriding default WooCommerce

  7. Hi,
    I have just tried the snippet and it works perfectly. However, what I need in addition to that is to show all the images in the gallery in the same size one below the other and without the slider.
    ยฟDo you know if this can be acheived easily?

    thanks!

    1. Hi Musta, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  8. Thanks; worked as expected!! Very helpful!

    1. Thank you Katie ๐Ÿ™‚

  9. Thank you! Is there a simple way to display the image caption below the image… the way it shows in the lightbox?
    I don’t need the zoom/lightbox feature but would like a caption for each image when selected from the slider.
    Tania

    1. Tania – thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  10. I use the Simple CSS plugin and your code works great with that
    Thanks!

    1. Cool ๐Ÿ™‚

  11. Thank you for this snippet! I have tested this code with Divi theme, WooCommerce 3.3.5 and a WordPress-friendly hosting on PHP 7.0.27.

    1. Thank you Noelle ๐Ÿ™‚

  12. I just noticed that zoom/slider and lightbox has been removed by default. Here is a good blog post that talks about the Gallery feature in WooCommerce.
    https://woocommerce.wordpress.com/2017/02/28/adding-support-for-woocommerce-2-7s-new-gallery-feature-to-your-theme/

    I have been searching and experimenting with ways to make the single featured product image non clickable and found out that this CSS solution works:

    /* Makes the featured single product image not clickable by changing the pointer. */
    .woocommerce div.product div.images .woocommerce-product-gallery__wrapper {
        pointer-events: none;
    }
    
    1. Thanks so much for your input Paal ๐Ÿ™‚

  13. Thanks! It works great!
    How do we also make it non clickable? As clicking it right now shows it like a regular clickable image that links to the media file.

    1. Hey Paal ๐Ÿ™‚ You would need to find in the WooCommerce templates where the image link is added, and after that use a provided filter (if any) to remove such a href. Hope this helps a little ๐Ÿ™‚

      1. That is what I wanted, too. I wrote this code to my functions.php and itโ€™s solved:

        function remove_full_size_image_link($image, $attachment_id, $size) {
          // is size == full?
          if($size == apply_filters( 'woocommerce_gallery_full_size', apply_filters( 'woocommerce_product_thumbnails_large_size', 'full' ) )) {
            return false;
          }
          return $image;
        }
        add_filter('wp_get_attachment_image_src', 'remove_full_size_image_link', 10, 3);
        
  14. We actually wrapped something like this into a plugin because we got so many requests for it ๐Ÿ™‚
    https://wordpress.org/plugins/woo-product-image-gallery-options/

    1. Cool Colm, thanks for that ๐Ÿ™‚

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *