Install NitroLiteBox, activate it, and your existing WordPress galleries and linked images gain a full-screen lightbox with pan & zoom, gallery grouping, and keyboard/touch navigation — no configuration required.
NitroLiteBox adds a full-screen lightbox to every linked image on your site. It loads just two files — a CSS file and a JS file — both deferred so they never block page rendering.
The plugin is designed to be set-and-forget: activate it and your existing WordPress gallery blocks, media links, and Oxygen Builder galleries immediately gain lightbox behaviour, with no classes or attributes to add.
transform and opacity. No layout thrashing.strategy: defer flag means the JS never blocks DOMContentLoaded.role="dialog", aria-modal, focus trap, focus-visible ring, and prefers-reduced-motion support.
nitrolitebox.zip and click Install Now.nitrolitebox.zip.nitrolitebox/ folder to /wp-content/plugins/.
| Requirement | Minimum | Notes |
|---|---|---|
| WordPress | 5.5 | Tested up to 6.7 |
| PHP | 7.4 | No PHP extensions required |
| Browser | ES6+ | All evergreen browsers; IE not supported |
| jQuery | Not required | |
Access all settings at Settings → NitroLiteBox in your WordPress admin. Changes are saved immediately and passed to the frontend via wp_localize_script.
nlb-group-)
These are all available configuration keys. They can be set via the Settings page or the nitrolitebox_options filter.
| Key | Type | Default | Description |
|---|---|---|---|
autoInit |
bool | true | Auto-detect <a><img> pairs in content |
selector |
string | "" | Extra CSS selectors (comma-separated) to lightbox |
captionSource |
string | "auto" | Where to read caption from: auto, title, alt, none |
loop |
bool | true | Loop from last image back to first (and vice versa) |
keyboard |
bool | true | Enable arrow key and Escape keyboard navigation |
swipe |
bool | true | Enable left/right swipe navigation on touch devices |
zoomIn |
bool | true | Scale-up entrance animation when image opens |
zoom |
bool | true | Enable full pan & zoom feature |
zoomMax |
number | 4 | Maximum zoom multiplier |
zoomStep |
number | 0.4 | Scroll-wheel zoom step size per tick |
groupClassPrefix |
string | "nlb-group-" | CSS class prefix for automatic gallery grouping |
counterPos |
string | "top" | Position of "1 / 4" counter: top, bottom, none |
Override any option programmatically using the nitrolitebox_options filter in your theme's functions.php. This takes priority over the Settings page.
add_filter( 'nitrolitebox_options', function( $options ) {
// Disable zoom on this site
$options['zoom'] = false;
// Increase max zoom
$options['zoomMax'] = 6;
// Use a custom class prefix for grouping
$options['groupClassPrefix'] = 'gallery-set-';
// Always use alt text for captions
$options['captionSource'] = 'alt';
return $options;
} );
When autoInit is true (the default), NitroLiteBox scans the page for any <a> element that:
href pointing to an image file (jpg, png, gif, webp, avif, svg, bmp, tiff)<img> elementThis matches the exact HTML output of WordPress core gallery blocks, the Classic Editor's "Link to media file" option, and Oxygen Builder's gallery widget.
<!-- This is detected and lightboxed automatically -->
<a href="image-full.jpg">
<img src="image-thumb.jpg" alt="A description">
</a>
To lightbox links that don't wrap an <img> (e.g. text links to images), add their CSS selector in Settings → Extra selectors or via the filter:
$options['selector'] = '.hero-section a, .portfolio-item > a';
Use the shortcode when you need precise control over the thumbnail, caption, or group assignment — especially useful in the Block Editor or Classic Editor.

| Parameter | Required | Default | Description |
|---|---|---|---|
src |
Yes | — | URL of the full-size image to display in the lightbox |
thumb |
No | Same as src | URL of the thumbnail to show on the page |
caption |
No | "" | Caption text shown in the lightbox overlay |
group |
No | Auto per-post ID | Group name for gallery navigation |
class |
No | "" | Extra CSS classes on the generated <a> tag |
width |
No | "" | Width attribute for the thumbnail <img> |
height |
No | "" | Height attribute for the thumbnail <img> |
When multiple images share a group identifier, clicking any one of them opens the full set as a browsable gallery with prev/next navigation and a "1 / 4" counter.
Add the same class starting with nlb-group- to any number of <a> tags. NitroLiteBox promotes the class to a group automatically.
<a href="photo1.jpg" class="nlb-group-portfolio"><img src="thumb1.jpg"></a>
<a href="photo2.jpg" class="nlb-group-portfolio"><img src="thumb2.jpg"></a>
<a href="photo3.jpg" class="nlb-group-portfolio"><img src="thumb3.jpg"></a>
<!-- All three are grouped — clicking any opens the full set -->
nlb-group- to any string in Settings or via $options['groupClassPrefix'].WordPress core gallery blocks already output rel="..." on all images in a gallery. NitroLiteBox reads this automatically — no changes needed.
<a href="photo1.jpg" rel="gallery-landscapes"><img src="thumb1.jpg"></a>
<a href="photo2.jpg" rel="gallery-landscapes"><img src="thumb2.jpg"></a>
For full manual control. Takes priority over class and rel if all three are present on the same element.
<a href="photo1.jpg" data-nlb-group="my-set">...</a>
<a href="photo2.jpg" data-nlb-group="my-set">...</a>
When an element has multiple group identifiers, NitroLiteBox uses this priority:
data-nlb-group attribute (highest priority)groupClassPrefixrel attribute
| Attribute | Element | Description |
|---|---|---|
data-nitrolitebox |
<a> | Explicitly mark any link as a lightbox trigger, even without an inner <img> |
data-nlb-group |
<a> | Assign to a named gallery group. All links sharing the same value form a gallery. |
data-nlb-caption |
<a> | Override caption text. Takes priority over title, alt, and figcaption. |
<a
href="https://example.com/image.jpg"
data-nitrolitebox
data-nlb-group="hero-set"
data-nlb-caption="The main event"
>
View full image
</a>
The zoom feature is enabled by default. All zoom operations use GPU-composited transform: scale() — no repaints, smooth even on low-end mobile.
| Input | Action |
|---|---|
| Scroll wheel | Zoom in/out toward cursor position (pointer-anchored) |
| Double-click | Zoom to 2.5× at click point; double-click again to reset |
| Pinch gesture | Two-finger pinch-to-zoom on mobile, anchored at pinch midpoint |
| Click & drag | Pan image while zoomed in (edge-clamped) |
| One-finger swipe (zoomed) | Pan image (swipe navigation disabled while zoomed) |
| Zoom button | Toggle 1× ↔ 2× via the magnifier button (top-right of lightbox) |
| + / = | Zoom in one step |
| - | Zoom out one step |
| 0 | Reset zoom to 1× |
| Esc | If zoomed: reset zoom. If not zoomed: close lightbox. |
add_filter( 'nitrolitebox_options', function( $opts ) {
$opts['zoom'] = false;
return $opts;
} );
| Input | Action |
|---|---|
| → Arrow Right | Next image |
| ← Arrow Left | Previous image |
| Esc | Reset zoom (if zoomed) or close lightbox |
| + / = | Zoom in one step |
| - | Zoom out one step |
| 0 | Reset zoom |
| Swipe left | Next image (when not zoomed) |
| Swipe right | Previous image (when not zoomed) |
| Swipe (when zoomed) | Pan the image |
| Pinch | Zoom in/out |
NitroLiteBox resolves caption text in this order when captionSource is set to auto:
data-nlb-caption attribute on the <a> (highest priority)title attribute on the <a>title attribute on the inner <img>alt attribute on the inner <img><figcaption> text inside an ancestor <figure>You can lock the source to a single attribute using the captionSource option: title, alt, or none.
As soon as a gallery image is shown, NitroLiteBox silently preloads the next and previous images using new Image() objects. Cached URLs are skipped. This means navigating to an adjacent image in the gallery is almost always instant.
NitroLiteBox exposes a global window.NitroLiteBox object with the following methods.
Programmatically open the lightbox with one or more images.
// Single image
NitroLiteBox.open('https://example.com/photo.jpg');
// Gallery of images — second argument is the starting index
NitroLiteBox.open([
{ src: 'https://example.com/a.jpg', caption: 'First photo' },
{ src: 'https://example.com/b.jpg', caption: 'Second photo' },
{ src: 'https://example.com/c.jpg' },
], 1); // opens at index 1 (second image)
Re-scans the DOM for newly added images. Call this after dynamically inserting content (AJAX, infinite scroll, Oxygen dynamic render, etc.).
// Call after inserting new content
fetch('/api/more-images').then(res => {
container.innerHTML = res.html;
NitroLiteBox.refresh(); // scan for new links
});
// Or dispatch the custom event
document.dispatchEvent(new CustomEvent('nlb:refresh'));
Close the lightbox programmatically.
Navigate to the next or previous image in the current gallery.
Set zoom to a specific multiplier (1 = normal, 2 = 2×, etc.). Animates to the new scale.
NitroLiteBox.setZoom(3); // zoom to 3×
NitroLiteBox.resetZoom(); // reset to 1×
| Event | Target | Description |
|---|---|---|
nlb:ready |
document | Fired once after the first DOM scan completes on DOMContentLoaded |
nlb:refresh |
document | Listen or dispatch to trigger a DOM re-scan |
// Know when NitroLiteBox has initialised
document.addEventListener('nlb:ready', () => {
console.log('NitroLiteBox ready');
});
// Trigger a re-scan from anywhere
document.dispatchEvent(new CustomEvent('nlb:refresh'));
NitroLiteBox detects whether Oxygen is active (via the CT_VERSION constant) and injects an extra re-init block in wp_footer. This calls NitroLiteBox.refresh() on both DOMContentLoaded and a custom oxygen-done event. Oxygen's gallery widgets output standard <a href="full.jpg"><img> markup, so auto-detection works without any extra configuration.
Elementor's gallery widget also outputs standard linked image markup. NitroLiteBox works out of the box. For AJAX-loaded Elementor sections, call NitroLiteBox.refresh() or dispatch nlb:refresh after the section loads.
Both output standard HTML. Auto-detection covers them automatically.
// After your builder/AJAX inserts new HTML:
NitroLiteBox.refresh();
// Or, if you prefer events:
document.dispatchEvent(new CustomEvent('nlb:refresh'));
nlb-group-* class auto-groups imagesNitroLiteBox.setZoom() and NitroLiteBox.resetZoom() to the JS APIzoom, zoomMax, zoomStep, groupClassPrefix to optionsrel and data-nlb-group
Only if both plugins bind click handlers to the same links. Disable autoInit in Settings and use data-nitrolitebox attributes or the shortcode on specific elements to avoid conflicts.
Yes. NitroLiteBox reads the href of the wrapping <a> tag to get the full-size URL, not the src of the thumbnail. Lazy-loading the thumbnail has no effect.
Yes — include nitrolitebox.css and nitrolitebox.js on any HTML page and call NitroLiteBox.refresh() after the DOM is ready. The PHP plugin wrapper is only needed for WordPress integration.
Call NitroLiteBox.refresh() after inserting the new HTML, or dispatch document.dispatchEvent(new CustomEvent('nlb:refresh')).
$opts['bgColor'] = 'rgba(20, 10, 30, 0.97)';
The tooltip is CSS-only and only appears on button hover. To hide it entirely, add to your theme CSS: #nlb-zoom-btn::after { display: none !important; }
Yes — SVG is in the image extension regex. Full-size SVG files open in the lightbox like any other image.
Yes. NitroLiteBox makes zero external requests. All assets load from your own server.