EC Lightbox is a minimal WordPress plugin that adds a modern lightbox to galleries using GLightbox.
The plugin is opt-in: it only activates where you explicitly add a custom CSS class to a block (e.g. a Gallery block). Everywhere else, WordPress behaves normally.
- Uses GLightbox for a clean, responsive lightbox.
- Works with WordPress core blocks (e.g. Gallery, Image).
- Opt-in activation via a custom CSS class (
ec-lightbox). - Groups images by gallery container (each block with
ec-lightboxis its own gallery). - No admin UI, no settings, no bloat – just enqueue + JS.
- Local vendor assets by default (no hard dependency on external CDNs).
- Optional support for loading GLightbox from a remote CDN via a WordPress filter.
- WordPress 5.0+
- PHP 7.0+
- A block-based setup (Gutenberg) is recommended.
-
Download or clone this repository into:
wp-content/plugins/ec-lightbox/ -
Ensure the plugin structure looks like this:
ec-lightbox/ ├─ ec-lightbox.php ├─ assets/ │ ├─ ec-lightbox.js │ ├─ ec-lightbox.css │ └─ vendors/ │ └─ glightbox/ │ ├─ glightbox.min.js │ └─ glightbox.min.css └─ README.md -
Activate EC Lightbox from the WordPress admin.
The plugin ships with local GLightbox files already included — no downloads needed.
- Insert a Gallery block.
- Select the whole gallery block (not a single image).
- In the right sidebar:
- Under Link settings, set:
- Link to →
None
- Link to →
- Under lightbox settings:
- Disable “Open in lightbox” or “Enlarge on click”.
- Open the Advanced panel.
- In Additional CSS class(es) enter:
To ensure EC Lightbox overrides WordPress behavior, you must:
- Add the class
ec-lightboxto the Gallery block. - Disable any click action on the gallery, inside the GB editor:
- Do not enable “Enlarge on click” / “Open in lightbox”.
- Set Link to =
None.
- Make sure individual images inside the gallery do not have click settings assigned.
If these WP-native actions remain enabled, WordPress will attach its own click/lightbox behavior, overriding this plugin.
A configuration screen is available at:
Settings → EC Lightbox
Available options:
-
Use CDN for GLightbox
Loads GLightbox assets from:
https://cdn.jsdelivr.net/npm/glightbox/
Instead of the bundled local vendor files. -
Loop images
-
Enable touch navigation
-
Enable zoom
-
Autoplay videos (for future video support)
All settings are passed directly to the lightbox JavaScript on initialization.
add_filter( 'ec_lightbox_use_cdn', '__return_false' ); // force local files
add_filter( 'ec_lightbox_use_cdn', '__return_true' ); // force CDN globallyThis overrides both plugin defaults and admin UI settings.
add_filter( 'ec_lightbox_js_options', function ( $options ) {
$options['loop'] = true;
$options['zoomable'] = false;
$options['openEffect'] = 'zoom'; // Any GLightbox option is accepted
return $options;
});Options merged from:
- Plugin defaults
- Admin settings
- This filter (highest priority)