Apply Lightbox to VC Single Image Element

The built-in lightbox that comes with this plugin can by default only be used with the elements that are specifically designed around it. The lightbox can not be automatically applied to image elements coming from Visual Composer itself (or other add-ons). As for the standard single image element that is native to Visual Composer, you can retroactively apply the lightbox with some custom JS code, provided you set the single image element to link to the large image version:

The first part of that code will parse all single image elements on the page and apply a transition effect and a group name to all those images.

The second part will then attempt to remove any prior lightbox scripts from the images and apply the new lightbox instead.

In order to ensure that the lightbox script itself is actually present, you should also enable the option “Load Lightbox On All Pages” in the plugin settings page (tab “External Files”). That will tell the plugin to ALWAYS load the lightbox script, even if no element from this plugin has been detected on the page.

This is an “out-of-the-box” usage of our built-in lightbox solution and therefore neither guaranteed to work, or supported by us. Whenever possible, please use the dedicated image elements from this add-on, which are specifically designed to work with the lightbox script.


Tekanewa has written 35 articles

Hi there, I am the Lead Developer here at Tekanewa Scripts by Kraut Coding; well, to be honest, I'm also the only developer. I love to create something beautiful and useful for Websites and here I write about how to use them. :)