Add WooCommerce LightBox Support Into Your Theme

Add WooCommerce LightBox Support Into Your Theme

With latest release of WooCommerce you experiencing a broken photo gallery and your Lightbox has gone missing after upgrading to WooCommerce 3.0 you’re not alone because it’s removed from WooCommerce 3.

WooCommerce 3.0 and the new gallery features

Image zoom / magnification built right into core – no need for any third party plugins for zoom functionality anymore!

Lightbox – brand new and much-improved image on the old one.

Slider – yip – no need for any advanced third party plugins for a nice slider for your photo gallery.

These are pretty big changes to how product images get presented in WooCommerce. Over the past few years, many third party extensions have become quite popular to address the previous shortcomings in core WooCommerce. For this reason, the WooCommerce team made the call to not enable the new gallery features by default.

In order to avail of these new features, you must be using a WooCommerce compatible theme that has specifically opted in to support the new gallery features. This also allows theme authors to pick and choose which new features they wish to support – while maintaining compatibility with their own theme features and/or compatibility with third-party WooCommerce gallery and Lightbox extensions.

Allowing theme authors to control which new gallery features are enabled is smart and is the right call by the WooCommerce team to minimize disruption to WooCommerce websites that have existing alternative product galleries.

The major downside to this approach though, is that if your WooCommerce theme doesn’t have it’s own gallery implementation and relies solely on the default WooCommerce Lightbox, chances are right now that your Lightbox is no longer working. Why? The old Lightbox has been completely deprecated and removed from the product page. So unless your theme author has already added support for the new 3.0 gallery features you’re caught in no mans land right now with no functioning Lightbox!

Adding support for the new WooCommerce 3.0 gallery features

The good news is that adding support for the new 3.0 gallery features is a piece of cake! If you’re using a WooCommerce supported theme that is maintained by a theme shop or a themeforest author my first recommendation is to get in touch with your theme author and ask them to add WooCommerce 3.0 support asap. If you’re managing your own WooCommerce theme you simply need to add a few lines to your after_setup_theme action. (most likely in your functions.php file).

If your theme hasn’t disabled the core WooCommerce styles that should be all you need to do to use the new gallery. But it’s quite common for themes that provide deep WooCommerce support to disable the core WooComerce styles and therefore you’ll need some additional CSS to get things looking nice. The following CSS is a slightly modified version of the css that ships with the Storefront WooCommerce theme. Try adding this to your themes style.css if you manage your own theme.

Just enjoy your new gallery!

Was this article helpful? If you’ve any question, let me know in comments!