In short
If your Divi lightbox stopped working after moving to Divi 5, the library behind it is probably still there: Divi 5 ships Magnific Popup but loads it only on pages it has recorded as needing a lightbox. The usual causes are an out-of-date record (clear Divi's CSS cache), a Gallery module set to Slider, a third-party gallery plugin Divi does not load the script for, or a script optimizer. This guide shows how to find yours and fix it, or switch to a gallery module with its own built-in lightbox.
From HappyDivi
HappyDivi Gallery
One Divi 5 module for galleries from WooCommerce, custom post types and ACF fields.
- Grid, Masonry and Justified layouts
- Built-in lightbox
30-day money-back guarantee
Why the Divi Lightbox Breaks in Divi 5 (The Real Reason)
If you upgraded from Divi 4 to Divi 5 and your gallery lightbox simply stopped opening (clicks do nothing, or open the bare image file), you are not alone. It is one of the most-searched Divi 5 problems in 2026, and the cause is rarely the setting you would expect.
Divi's lightbox is Magnific Popup, a jQuery-based library. Divi 4 used it and Divi 5 still ships it. What changed is when it loads: Divi 5 loads Magnific Popup, and jQuery with it, only on pages it has recorded as needing a lightbox. That means a Gallery module, an Image module set to Open in Lightbox, a WordPress gallery block, an Instagram feed or a WooCommerce product gallery. When that record is wrong, or the gallery comes from a plugin Divi does not load the library for, the lightbox never starts.
We checked this on Divi 5.15.1: a Divi 5 Gallery in Grid layout, a Divi 4 gallery that was never converted, and an Image module set to Open in Lightbox all opened their lightbox once Divi's record of the page was up to date.
This affects:
- Pages whose cached record was made before the gallery was added
- Divi Gallery modules set to Slider, which never open a lightbox
- Third-party Divi gallery plugins that expect Divi to load Magnific Popup for them
- Sites where a script optimizer delays, combines or removes jQuery or the lightbox script
Before you start
Most "fixes" you will find online load Magnific Popup again from a CDN on every page. On Divi 5 that is usually unnecessary: the library is already in the theme, it just was not loaded on that page. Find your cause first.
The Three Root Causes (Diagnose Yours First)
Before you start clicking through settings, take sixty seconds to identify which of these three situations you are in. The right fix depends entirely on the cause.
Cause 1: Divi Did Not Load the Lightbox Script on That Page
Divi 5 decides which scripts a page needs from a cached record of the modules on it, and loads Magnific Popup only when that record lists a gallery or a lightbox image. That record is refreshed when an editor saves the page in WordPress. A page changed by a script, an import or a sync tool with no editor logged in, or on a server where Divi cannot write its cache folder, can keep an old record. The gallery then shows, but its lightbox script is never loaded.
Galleries from third-party Divi plugins can hit the same wall. Divi 5 loads the library for its own modules and for a short list of known third-party gallery shortcodes, not for every plugin that relied on it in Divi 4.
How to confirm
Open the page, press F12, type jQuery.fn.magnificPopup in the Console and press Enter. undefined means the library was not loaded on this page. An error saying jQuery is not defined points to the same cause: nothing on the page asked for it.
Cause 2: The Divi 5 Gallery Module Is Set to Slider
The native Divi 5 Gallery module has no lightbox toggle. Its lightbox follows the layout: Grid opens images in a lightbox, while Slider shows one image at a time and never does.
How to confirm
Open the Gallery module, then the Design tab and its Layout group. If it is set to Slider, that is your answer.
Cause 3: A Plugin or Theme Conflict Is Blocking the Script
Caching plugins (WP Rocket, W3 Total Cache, LiteSpeed Cache), minification settings, or another gallery plugin can strip, defer, or conflict with whatever lightbox script is meant to load.
How to confirm
Deactivate all caching plugins temporarily and test in an incognito window with browser cache cleared. If the lightbox works after that, a caching or minification rule is the culprit.
Fix 1: Make the Divi 5 Gallery Module Open Its Lightbox
Divi 5's own Gallery module has no lightbox switch. In Grid layout it opens every image in Divi's built-in lightbox automatically; in Slider layout it never opens one. So the checks are short:
Open the page in the Divi 5 Visual Builder
Click the Gallery module, then open the Design tab and its Layout group
Set the layout to Grid
Slider shows one image at a time and has no lightbox.
Save, then clear Divi's cache
Go to Divi, Theme Options and click Clear CSS Cache at the top of the page. Divi 5 loads its lightbox script only on pages it has recorded as needing one. That record is refreshed when an editor saves the page in WordPress. A page changed by a script, an import or a sync tool with no editor logged in, or on a server where Divi cannot write its cache folder, can keep an old record.
Preview on the front end
Clicking an image should open the lightbox, not the bare image file. If it still opens the file, or the lightbox looks broken (missing arrows, broken layout, images that do not zoom), continue to Fix 3 below: a plugin conflict is likely.
Fix 2: Load Divi's Lightbox Script for a Third-Party Gallery
Use this when a gallery from another Divi plugin expects Magnific Popup and Divi 5 does not load it for that plugin. Rather than adding a second copy from a CDN, load the one Divi already ships.
Important caveats before you do this
This loads jQuery and Magnific Popup on every page and post, gallery or not, which adds page weight. Narrow the is_singular() check to the pages that hold the plugin's galleries. The two file paths are inside the Divi theme and can change in an update, so test the lightbox after every Divi update. This is a bridge, not a destination.
How to do it
Add the following to your child theme's functions.php or via a code snippet plugin:
PHP
add_action( 'wp_enqueue_scripts', function () {
// Only where the third-party gallery is used.
if ( ! is_singular() ) {
return;
}
$divi = get_template_directory_uri();
wp_enqueue_script(
'magnific-popup',
$divi . '/includes/builder-5/visual-builder/build/script-library-magnific-popup.js',
[ 'jquery' ],
ET_CORE_VERSION,
true
);
wp_enqueue_style(
'magnific-popup',
$divi . '/includes/builder/feature/dynamic-assets/assets/css/magnific_popup.css',
[],
ET_CORE_VERSION
);
}, 20 );After adding this code
Clear Divi's CSS cache and any page cache, then test. If jQuery.fn.magnificPopup is now a function but images still do not open, the plugin's own lightbox code is not running on Divi 5. Ask its developer, or use Fix 3 or Fix 4.
Fix 3: Check Plugin and Caching Conflicts
This step resolves the majority of "it used to work, now it doesn't" lightbox problems that are not directly caused by the Divi 4 → 5 migration.
Step 3a: Disable Script Optimization and Minification
In WP Rocket, LiteSpeed Cache, or W3 Total Cache, look for:
- Combine JS files: disable this.
- Defer JavaScript execution: disable or add exceptions for Divi and lightbox scripts.
- Minify JavaScript: try disabling to test.
In Divi itself: Divi → Theme Options → General → Performance: check whether "Defer Third-Party Scripts" or "Critical CSS" settings are interfering.
Step 3b: Deactivate Plugins One at a Time
Use the standard "binary search" approach: deactivate half your plugins, test, narrow down to the conflicting one. Plugins most commonly responsible for Divi lightbox conflicts include:
- Autoptimize
- Hummingbird (when JS optimization is on)
- Flying Scripts
- Asset CleanUp Pro (when jQuery is excluded from certain pages)
Step 3c: Test with the Default WordPress Theme
Temporarily switch to Twenty Twenty-Four to rule out a child theme conflict. If the lightbox works with the default theme, a customization in your child theme's functions.php or CSS is stripping the scripts.
Fix 4: Use a Gallery Module With Its Own Built-In Lightbox
This is the correct long-term fix, and the one that gives you the most features.
Divi's own lightbox is fragile for the same reason in Divi 4 and Divi 5: it depends on a shared jQuery plugin that has to be loaded on the right pages. A stale cache, a plugin conflict or a script optimizer can break it. The modern, Divi 5-native approach is to use a gallery module that ships its own self-contained lightbox: one that does not depend on jQuery, Magnific Popup, or any other globally-loaded library.
HappyDivi Gallery takes exactly this approach. The built-in lightbox is a zero-dependency overlay written in vanilla JavaScript. It only downloads when a visitor actually clicks an image (code-split, on demand), and it works reliably regardless of what other plugins are active on your site.
The built-in lightbox: toolbar, arrows, title and caption, a counter and the thumbnail filmstrip.
Here is what the HappyDivi Gallery built-in lightbox includes: features that go well beyond what Divi's Magnific Popup lightbox offers:
| Feature | Divi Magnific Popup | HappyDivi Gallery Lightbox |
|---|---|---|
| Basic image overlay | ✓ Yes | ✓ Yes |
| Keyboard navigation (← →) | ✓ Yes | ✓ Yes |
| ESC to close | ✓ Yes | ✓ Yes |
| Touch swipe navigation | ⚠ Limited | ✓ Full swipe left/right |
| Swipe down to close | ✗ No | ✓ Yes |
| Pinch-to-zoom | ✗ No | ✓ Up to 4× |
See the other 12 rows
| Feature | Divi Magnific Popup | HappyDivi Gallery Lightbox |
|---|---|---|
| Double-tap to zoom | ✗ No | ✓ Yes |
| Drag to pan when zoomed | ✗ No | ✓ Yes |
| Thumbnail filmstrip | ✗ No | ✓ Toggleable |
| Image counter ("3 / 24") | ✗ No | ✓ Yes |
| EXIF / metadata info panel | ✗ No | ✓ Yes |
| Download button | ✗ No | ✓ Yes |
| Native share sheet (mobile) | ✗ No | ✓ Yes |
| Fullscreen API | ✗ No | ✓ Yes |
| WooCommerce price + cart in lightbox | ✗ No | ✓ Yes |
| prefers-reduced-motion respected | ✗ No | ✓ Yes |
| role="dialog" + focus trap (accessible) | ✗ No | ✓ Yes |
| jQuery dependency | ✗ Required | ✓ Zero dependencies |
From HappyDivi
HappyDivi Gallery
One Divi 5 module for galleries from WooCommerce, custom post types and ACF fields.
- Grid, Masonry and Justified layouts
- Built-in lightbox
30-day money-back guarantee
How to Set Up the HappyDivi Gallery Lightbox, Step by Step
If you decide to move to HappyDivi Gallery (the recommended path for any Divi 5 site), here is exactly how to configure the lightbox.
Step 1: Install and Activate HappyDivi Gallery
Purchase and download HappyDivi Gallery from happydivi.com/gallery. Install it as a standard WordPress plugin (Plugins → Add New → Upload Plugin). Activate it. No additional configuration is needed: the plugin registers itself with Divi 5 automatically on activation.
Step 2: Add the HappyDivi Gallery Module to Your Page
Open the page in the Divi 5 Visual Builder. Click the blue + button to add a new module. Search for "HappyDivi": the HappyDivi Gallery module appears in the module list. Insert it.
Step 3: Choose Your Content Source
In the Content tab → Image / Content Source group, choose where the gallery pulls its images from:
- Media Library: hand-pick photos you have uploaded.
- Posts / Pages: auto-pulls featured images from any post or page.
- Custom Post Type: point at any registered CPT.
- WooCommerce Products: product images with shopping features.
- ACF Image / Gallery Field: images from Advanced Custom Fields.
One module, five content sources. Media Library shows the images you picked; the others fill the gallery from posts, products or ACF fields.
For a basic portfolio or photo gallery replacing a broken Divi 4 gallery, choose Media Library and select your images.
Step 4: Enable the Lightbox
In the Content tab → Click Action group, set Click Action to Open in Lightbox. The lightbox toolbar options appear below. Decide which buttons to show:
- Thumbnails (filmstrip at bottom): recommended for photo galleries.
- Info Panel: shows EXIF data for photos; great for photography portfolios.
- Zoom: allows in-lightbox zoom; recommended.
- Download: lets visitors download the full image.
- Fullscreen: enters browser fullscreen.
- Share: native share sheet on mobile, clipboard copy on desktop.
Content tab, Click Action: choose Open in Lightbox, then switch each lightbox button on or off.
Recommended starting point
For most galleries, enabling Thumbnails + Zoom + Fullscreen is the right combination. Toggle the others based on whether your use case involves downloadable photos, products, or private content.
Step 5: Choose Your Gallery Layout
In the Content tab → Gallery Layout group:
- Grid: clean uniform cells, best for product galleries or portfolios where consistency matters.
- Masonry: Pinterest-style variable heights, best for photography where you do not want images cropped.
- Justified: Flickr-style flush rows, best for photo sets where you want every image to touch its neighbour edge-to-edge.
Pro recommendation
For a photography gallery where lightbox quality matters most, Justified + Lightbox is the professional standard. Set target row height to 220 px on desktop and 160 px on mobile.
Step 6: Configure Lazy Loading
In the Content tab → Lazy Loading group, choose a placeholder mode:
- Blur-up (default): low-res blur fades to sharp as each image loads. The most polished option.
- Skeleton shimmer: a pulsing grey shape holds the space while the image loads. More app-like.
- None: image appears when fully loaded, no placeholder.
Performance tip
If your gallery is above the fold, the first thing visitors see, turn Enable Lazy Loading off entirely for the fastest possible first paint.
Step 7: Save and Test
Click Save in the Visual Builder. Open the page in a fresh incognito window. Click any image. The lightbox should open immediately, with arrows, keyboard navigation, and all your chosen toolbar buttons. Test on mobile: swipe left/right to navigate, swipe down to close.
The Divi 5 Lightbox Settings You Might Have Missed
Whether you are using the native Divi 5 gallery or HappyDivi Gallery, here are the settings that are most often overlooked.
Thumbnail Filmstrip
The filmstrip (a scrollable row of small thumbnails at the bottom of the lightbox) makes it easy for visitors to jump to any image in a large gallery without clicking through one by one. In HappyDivi Gallery, it is toggled under Click Action → Lightbox → Thumbnails.
Info Panel for Photography and WooCommerce
For photography galleries, the Info Panel shows real EXIF metadata (camera model, aperture, ISO, shutter speed) pulled directly from the image file's embedded data. For WooCommerce galleries, the Info Panel shows product price and an Add to Cart button, so visitors can shop without leaving the lightbox. This is configured under Click Action → Lightbox → Info Panel.
The Info panel open. This photo carries no EXIF data, so only its dimensions show; camera settings appear when the file includes them.
Share Button Behavior
On desktop, the Share button copies the direct image URL to the clipboard and shows a brief "Copied!" toast. On mobile, it triggers the native OS share sheet (the same one you get when sharing from apps). If you are building a public photography site and want images to be shareable, turn this on. If you are building a private client gallery or a B2B portfolio, turn it off.
Fullscreen API
The Fullscreen button uses the browser's native Fullscreen API: the same mechanism used by YouTube and Netflix. The image expands to cover the entire monitor with true fullscreen (not just a maximised browser window). This is particularly impactful for landscape photography and architectural work.
prefers-reduced-motion
All HappyDivi Gallery lightbox transitions (the open animation, the image-change crossfade, the toolbar fade-ins) are automatically disabled for any visitor whose operating system has "Reduce Motion" enabled. This is common among users with vestibular disorders or motion sensitivity. There is no setting to configure; it works automatically.
Common Divi Lightbox Problems and Their Exact Solutions
Here are the most-reported Divi lightbox issues on forums and their confirmed fixes.
"The lightbox opens but shows a broken image / 404"
Cause: The image URL being passed to the lightbox is wrong: often a relative path that becomes invalid in a subdirectory install, or a URL that points to a thumbnail size rather than the full image.
Fix: In HappyDivi Gallery → Content tab → Gallery Layout → Image Size, set this to Large or Full Size. Serving thumbnails to the lightbox is a common misconfiguration: thumbnails are meant for the grid cells, not for the full-size view.
"The lightbox works on desktop but clicking images on mobile does nothing"
Cause: A CSS rule is absorbing the click event before the JavaScript can intercept it. Often caused by a theme's global pointer-events: none on certain elements, or a touch event handler in another plugin that calls event.stopPropagation().
Fix in HappyDivi Gallery: This does not occur because HappyDivi Gallery uses its own isolated event listeners on its own DOM elements. If you are experiencing this with the native Divi gallery, inspect the element in mobile DevTools and look for any style or script overriding the click target.
"The lightbox opens but the arrows are missing"
Cause: Missing CSS. Either the lightbox stylesheet was not loaded (caching issue) or a plugin's CSS override is hiding the arrow elements.
Fix: Clear all caches including the browser cache. Check for CSS rules targeting .mfp-arrow (Magnific Popup) or your gallery's arrow classes. In HappyDivi Gallery, the lightbox CSS is self-contained and loaded on-demand; if arrows are missing it typically means the CSS file was not served: check your hosting's file permissions or a CDN origin issue.
"The lightbox opens but is completely unstyled, no backdrop, white background"
Cause: The lightbox CSS file failed to load, most commonly because a minification tool corrupted the file or an aggressive caching plugin cached a version from before the plugin was activated.
Fix: Deactivate all caching and minification plugins, clear all caches, then retest. If it works, re-enable caching one feature at a time until you find the conflicting optimisation rule.
"The lightbox worked, then broke after a Divi update"
Cause: Divi updates occasionally change how modules register their scripts and styles. A new Divi 5 version may have removed a compatibility shim that was keeping your old lightbox working.
Key Point
This is the strongest argument for using HappyDivi Gallery instead of relying on Divi's internal lightbox implementation. Because HappyDivi Gallery ships its own lightbox code independently, it is not affected by changes to Divi's internal script loading. HappyDivi plugin updates are fully independent of Elegant Themes updates.
"I want the lightbox to show images from a WooCommerce product gallery, not just the featured image"
Cause: The native Divi gallery module has no WooCommerce integration: it can only display images you manually pick from the Media Library.
Fix: This is where HappyDivi Gallery's WooCommerce Products source and Product Carousel settings become essential. With source set to WooCommerce Products and the Product Carousel enabled, each gallery cell shows a mini slideshow of all product images. When clicked, the lightbox displays the full-resolution version of whichever slide is currently showing. The Info Panel inside the lightbox shows the product price and an Add to Cart button.
Understanding the HappyDivi Gallery Lightbox Architecture
For technically curious readers, web developers and agency leads who want to understand why HappyDivi Gallery's lightbox is more reliable than Magnific Popup, here is a brief explanation.
Magnific Popup is a jQuery plugin, meaning it requires jQuery to be loaded globally before it runs, attaches click handlers by querying the entire DOM with $('.mfp-gallery'), and shares a single global namespace that any other script can accidentally overwrite.
HappyDivi Gallery's lightbox is architected differently across four key points:
Written in vanilla ES2020: no jQuery dependency at all
Code-split
The lightbox JavaScript chunk is only downloaded when a visitor clicks their first image. On pages where nobody opens the lightbox, the code is never fetched.
Scoped
It attaches to its own module's DOM elements using direct references, not global class selectors. Other plugins cannot accidentally interfere.
Server-side rendered
Gallery HTML (the <figure> elements, images, and data- attributes) is generated by PHP on the server. Visitors see the gallery immediately, before any JavaScript loads. The lightbox JS then progressively enhances this existing HTML.
This architecture is why HappyDivi Gallery's lightbox does not break when you add a new plugin, update Divi, or enable aggressive caching.
When to Use Each Fix: A Decision Tree
Decision tree
Does clicking an image do nothing, or open the bare image file?
├── Is it Divi's own Gallery module?
│ ├── Layout set to Slider → switch it to Grid (Fix 1)
│ └── Grid, still no lightbox → clear Divi's CSS cache (Fix 1)
│ └── Still broken → look for a plugin conflict (Fix 3)
├── Is it a gallery from another Divi plugin?
│ └── Load Divi's lightbox script for it (Fix 2), or check that plugin's docs
└── Want a lightbox that does not depend on Divi's script at all?
└── Use HappyDivi Gallery (Fix 4)If you are building a new page from scratch, no migration involved, the answer is straightforward: use HappyDivi Gallery from the start. You get a modern, reliable, feature-rich lightbox that requires no workarounds and is designed specifically for Divi 5's React-based architecture.
HappyDivi Gallery: The Guaranteed-Works Lightbox for Divi 5
HappyDivi Gallery is a premium gallery module for Divi 5 that adds five dynamic content sources (Media Library, Posts, Custom Post Types, ACF fields, and WooCommerce Products), three layout engines (Grid, Masonry, and Justified), a zero-dependency built-in lightbox, an animated filter bar, and three pagination modes, all from a single module inside the Visual Builder, with no shortcodes and zero jQuery.
The built-in lightbox covers every scenario:
- Photography portfolio: Justified layout + lightbox with EXIF panel + pinch zoom + download button.
- WooCommerce shop: product images with per-cell carousel + lightbox showing price and Add to Cart.
- Client gallery: lightbox with download enabled, share disabled, info panel off.
- Blog post grid: Masonry layout, click action set to "Go to Post URL" instead of lightbox for SEO-friendly navigation.
The complete package
The entire module is vanilla ES2020, code-split, server-side rendered, and fully accessible: role="dialog", focus trap, aria-modal, and prefers-reduced-motion support all included out of the box.
From HappyDivi
HappyDivi Gallery
One Divi 5 module for galleries from WooCommerce, custom post types and ACF fields.
- Grid, Masonry and Justified layouts
- Built-in lightbox
30-day money-back guarantee
Related Reading
- The Complete Divi 5 Gallery Guide: the full reference covering every HappyDivi Gallery feature.
- 10 Things the Divi Gallery Module Cannot Do: an honest look at the Divi Gallery module and your options.
- Photography and Real Estate Galleries in Divi 5: two complete builds, including full lightbox settings.
Frequently asked questions
Does Divi 5 have a lightbox built in?
Yes. Divi 5 still ships Magnific Popup, the lightbox Divi 4 used, and loads it for the Gallery module (Grid layout opens the lightbox) and for Image modules set to Open in Lightbox. There is no separate lightbox toggle on the Gallery module. If it stopped working, check the layout and clear Divi's CSS cache (Fix 1), then look for a script optimizer or plugin conflict (Fix 3). Or use a module like HappyDivi Gallery that ships its own self-contained lightbox.
Why did my Divi lightbox suddenly stop working after a Divi update?
Divi 5 loads its lightbox script only on pages it has recorded as needing one, and an update can leave cached files and that record out of date. Clear Divi's CSS cache in Theme Options and any caching plugin, then test again. If the broken gallery comes from a third-party plugin, it may rely on Divi loading Magnific Popup for it (see Fix 2).
Will adding jQuery back fix the Divi 5 lightbox?
Usually not, because jQuery is rarely what is missing: Divi 5 loads it whenever its lightbox needs it. If the lightbox script did not load, clear Divi's CSS cache first (Fix 1). For a third-party plugin's gallery, load Divi's own copy of the script (Fix 2) rather than a second one from a CDN.
Can HappyDivi Gallery's lightbox display WooCommerce product information?
Yes. When the content source is set to WooCommerce Products, the lightbox's Info Panel shows product price, sale status, and an Add to Cart button directly inside the lightbox overlay. Visitors can add products to the cart without closing the lightbox and without a page reload.
Is HappyDivi Gallery's lightbox accessible for screen reader users?
Yes. The lightbox is a proper role="dialog" with aria-modal="true" and a descriptive aria-label. A focus trap keeps keyboard focus inside the lightbox while it is open so screen reader users cannot accidentally interact with the page behind it. All toolbar buttons have aria-label attributes. All transition animations respect the visitor's prefers-reduced-motion OS setting.
Does the lightbox work on mobile without installing anything extra?
Yes. Touch swipe left/right to navigate, swipe-down to close, pinch-to-zoom, and double-tap to zoom are all built into the HappyDivi Gallery lightbox with no additional configuration or plugins required.
From HappyDivi
HappyDivi Gallery
One Divi 5 module for galleries from WooCommerce, custom post types and ACF fields.
- Grid, Masonry and Justified layouts
- Built-in lightbox
30-day money-back guarantee









