Technical reference for developers working with the FotoGrids Lightbox — custom events, HTML trigger attributes, the data-fg-lb-* settings system, and the REST endpoint the info panel uses.
Audience: Developers building custom themes, rendering galleries outside WordPress, or extending Lightbox behavior with JavaScript.
Custom Events #
The Lightbox dispatches three custom events on the gallery wrapper element (the .fotogrids-gallery element that wraps the items). Listen at the gallery level to scope handlers to a specific gallery. Events also bubble, so document-level listeners work.
fotogrids:lightbox:open
Fired when the Lightbox opens on an item.
galleryEl.addEventListener( 'fotogrids:lightbox:open', ( e ) => {
const { galleryEl, index, item } = e.detail;
} );
| Property | Type | Description |
|---|---|---|
galleryEl | Element | The gallery wrapper that was opened |
index | number | Zero-based index of the item that was clicked |
item | object | Item data object (see Item Object below) |
fotogrids:lightbox:navigate
Fired each time the visitor moves to a different item — by arrow, dot, keyboard, swipe, or thumbnail click.
galleryEl.addEventListener( 'fotogrids:lightbox:navigate', ( e ) => {
const { galleryEl, index, item, direction } = e.detail;
} );
| Property | Type | Description |
|---|---|---|
galleryEl | Element | The gallery wrapper currently open |
index | number | Zero-based index of the item now displayed |
item | object | Item data object for the new item |
direction | 'next' | 'prev' | Which direction the visitor navigated |
fotogrids:lightbox:close
Fired when the Lightbox closes, before focus is returned to the trigger element.
galleryEl.addEventListener( 'fotogrids:lightbox:close', ( e ) => {
const { galleryEl } = e.detail;
} );
| Property | Type | Description |
|---|---|---|
galleryEl | Element | The gallery wrapper that was open |
Item Object
The item object passed in open and navigate events:
{
triggerEl, // Element — the <a> with [data-fg-lightbox-trigger] that was clicked
fullSrc, // string — URL of the full-size image/video (href of the trigger)
thumbSrc, // string — URL of the thumbnail (src of the <img> inside the trigger)
alt, // string — alt text of the thumbnail image
caption, // string — value of data-fg-caption on the trigger
title, // string — value of data-fg-title on the trigger
id, // string — value of data-fg-item-id on the trigger (used for REST fetch)
}
HTML Trigger Attributes #
The Lightbox is initialised entirely from the DOM — no JavaScript configuration object is required.
On the gallery wrapper element
| Attribute | Value | Description |
|---|---|---|
data-fg-click | "lightbox" | Marks this gallery as Lightbox-enabled. The Lightbox init script scans for this attribute and wires click handlers. |
On each item’s <a> link
| Attribute | Description |
|---|---|
data-fg-lightbox-trigger | Present (no value needed) — marks this link as a Lightbox trigger. |
href | Full-size media URL — what the Lightbox actually displays. |
data-fg-item-id | The item’s ID — used to fetch info panel data from the REST API. |
data-fg-caption | Caption text — shown in the info panel immediately (no REST fetch needed). |
data-fg-title | Title text — available in the item event object. |
A minimal hand-authored gallery structure:
<div class="fotogrids-gallery" data-fg-click="lightbox" data-fg-lb-theme="dark">
<figure>
<a href="https://example.com/photo-full.jpg"
data-fg-lightbox-trigger
data-fg-item-id="42"
data-fg-caption="Sunrise over the valley">
<img src="https://example.com/photo-thumb.jpg" alt="Sunrise over the valley">
</a>
</figure>
<figure>
<a href="https://example.com/photo2-full.jpg"
data-fg-lightbox-trigger
data-fg-item-id="43"
data-fg-caption="Golden hour">
<img src="https://example.com/photo2-thumb.jpg" alt="Golden hour">
</a>
</figure>
</div>
The data-fg-lb-* Settings System #
All Lightbox settings are read from data-fg-lb-* attributes on the gallery wrapper at open time. The PHP renderer writes these from the gallery’s stored settings — but they can be set or overridden directly in HTML.
Boolean attributes: Present means enabled, absent means disabled — no value is needed (e.g. data-fg-lb-fit-media with no ="true"). The naming convention flips for no- prefixed attributes: data-fg-lb-no-loop present means loop is disabled.
Theme & Colors
| Attribute | Type | Default | Description |
|---|---|---|---|
data-fg-lb-theme | "dark" | "light" | "custom" | "dark" | Color theme |
data-fg-lb-bg | rgba string | — | Backdrop color (custom theme) |
data-fg-lb-toolbar-bg | rgba string | — | Toolbar background (custom theme) |
data-fg-lb-toolbar-btn-color | rgba string | — | Toolbar button icon color (custom theme) |
data-fg-lb-toolbar-btn-hover | rgba string | — | Toolbar button hover color (custom theme) |
data-fg-lb-toolbar-btn-active-bg | rgba string | — | Active button background (custom theme) |
data-fg-lb-arrow-bg | rgba string | — | Arrow button background (custom theme) |
data-fg-lb-arrow-bg-hover | rgba string | — | Arrow button hover background (custom theme) |
data-fg-lb-arrow-color | rgba string | — | Arrow icon color (custom theme) |
data-fg-lb-arrow-hover-color | rgba string | — | Arrow icon hover color (custom theme) |
data-fg-lb-bullet-color | rgba string | — | Inactive dot color (custom theme) |
data-fg-lb-bullet-hover-color | rgba string | — | Dot hover color (custom theme) |
data-fg-lb-bullet-active-color | rgba string | — | Active dot color (custom theme) |
data-fg-lb-thumbs-bg | rgba string | — | Thumbnail strip background (custom theme) |
data-fg-lb-thumb-border-color | rgba string | — | Thumbnail border color (custom theme) |
data-fg-lb-thumb-active-color | rgba string | — | Active thumbnail highlight (custom theme) |
data-fg-lb-info-bg | rgba string | — | Info panel background (custom theme) |
data-fg-lb-info-block-bg | rgba string | — | Info block background (custom theme, boxed style) |
data-fg-lb-info-block-divider | rgba string | — | Divider color between blocks (custom theme, divided style) |
data-fg-lb-info-text | rgba string | — | Info panel body text color (custom theme) |
data-fg-lb-info-title | rgba string | — | Info panel title color (custom theme) |
data-fg-lb-spinner-color | rgba string | — | Loading spinner color (custom theme) |
data-fg-lb-img-shadow | rgba string | — | Item shadow color (custom theme) |
data-fg-lb-progress-color | rgba string | — | Progress bar/spinner color (custom theme) |
Layout & Behavior
| Attribute | Type | Default | Description |
|---|---|---|---|
data-fg-lb-overlay-blur | integer (px) | 8 | Backdrop blur intensity (attribute absent = 8; set to 0 for no blur) |
data-fg-lb-fit-media | boolean attr | absent = off | Scale items to fit the viewport |
data-fg-lb-mobile-layout | "mobile_optimized" | "desktop" | "mobile_optimized" | Mobile layout mode |
data-fg-lb-fullscreen | boolean attr | absent = off | Show fullscreen button |
data-fg-lb-no-tooltips | boolean attr | absent = off | Present to disable button tooltips |
data-fg-lb-no-backdrop-close | boolean attr | absent = off | Prevent closing by clicking the backdrop |
Navigation & Transition
| Attribute | Type | Default | Description |
|---|---|---|---|
data-fg-lb-transition | "fade" | "horizontal" | "vertical" | "none" | "fade" | Transition style between items |
data-fg-lb-duration | integer (ms) | 300 | Transition duration |
data-fg-lb-no-loop | boolean attr | absent = loop on | Present to disable looping |
data-fg-lb-hide-arrows-at-ends | boolean attr | absent = off | Hide arrows at first/last item when loop is off |
data-fg-lb-show-arrows | boolean attr | absent = off | Show prev/next navigation arrows |
data-fg-lb-arrow-icon | "chevron" | "chevron_double" | "arrow" | "arrow_narrow" | "arrow_square" | "arrow_circle" | "arrow_circle_broken" | "arrow_block" | "chevron" | Arrow icon style |
data-fg-lb-arrow-prev | SVG string | ‹ | Previous arrow icon SVG (written by PHP from arrow-icons.json; override to supply a custom SVG) |
data-fg-lb-arrow-next | SVG string | › | Next arrow icon SVG (written by PHP from arrow-icons.json; override to supply a custom SVG) |
data-fg-lb-arrow-size | integer (px) | 40 | Arrow icon size |
data-fg-lb-show-dots | boolean attr | absent = off | Show dot navigation |
data-fg-lb-dot-style | "fill" | "stroke" | "square" | "square_stroke" | "fill" | Dot style |
data-fg-lb-dot-size | integer (px) | 12 | Dot size |
data-fg-lb-dots-spacing | CSS length | "8px" | Spacing between dots |
data-fg-lb-show-counter | boolean attr | absent = off | Show item counter in toolbar |
Auto-Progress
| Attribute | Type | Default | Description |
|---|---|---|---|
data-fg-lb-auto-progress | boolean attr | absent = off | Enable auto-progress |
data-fg-lb-auto-delay | integer (seconds) | 5 | Delay between auto-advances |
data-fg-lb-progress-style | "bar" | "spinner" | "none" | "bar" | Progress indicator style |
data-fg-lb-progress-bar-loc | "top" | "right" | "bottom" | "left" | "bottom" | Progress bar position |
data-fg-lb-progress-pause-on | space-separated tokens | "image_hover" | What pauses auto-progress (image_hover, thumbnail_hover) |
data-fg-lb-progress-stop | boolean attr | absent = off | Stop permanently on user interaction |
data-fg-lb-progress-controls | boolean attr | absent = off | Show play/pause button in toolbar |
Thumbnail Strip
| Attribute | Type | Default | Description |
|---|---|---|---|
data-fg-lb-thumbnail-location | "bottom" | "top" | "left" | "right" | "none" | "bottom" | Strip position |
data-fg-lb-thumbnail-size | "small" | "normal" | "large" | "normal" | Thumbnail size |
data-fg-lb-thumb-spacing | integer (px) | 5 | Space between thumbnails |
data-fg-lb-no-thumb-drag | boolean attr | absent = drag on | Present to disable mouse drag |
data-fg-lb-no-thumb-swipe | boolean attr | absent = swipe on | Present to disable touch swipe |
Zoom
| Attribute | Type | Default | Description |
|---|---|---|---|
data-fg-lb-zoom | boolean attr | absent = off | Enable zoom |
data-fg-lb-zoom-trigger | "double_click" | "click" | "wheel_pinch" | "double_click" | Zoom activation method |
data-fg-lb-zoom-icons | boolean attr | absent = off | Show zoom in/out buttons in toolbar |
data-fg-lb-zoom-beyond | boolean attr | absent = off | Allow zoom beyond original resolution |
Info Panel
| Attribute | Type | Default | Description |
|---|---|---|---|
data-fg-lb-info-panel | "always" | "on_click" | "never" | "always" | Info panel visibility mode |
data-fg-lb-info-location | "left" | "right" | "bottom" | "right" | Info panel position |
data-fg-lb-info-blocks | space-separated block IDs | all blocks | Which info blocks to render |
data-fg-lb-info-blocks-style | "boxed" | "divided" | "plain" | "boxed" | Block layout style |
data-fg-lb-credit-source | "item_meta" | "exif" | "item_meta" | Credit text source |
data-fg-lb-exif-fields | space-separated field keys | [] | Which EXIF fields to show |
Info block IDs (for data-fg-lb-info-blocks):caption description file_info exif share credit tags people location rating download
EXIF field keys (for data-fg-lb-exif-fields):camera aperture shutter_speed iso lens focal_length date_taken copyright orientation flash white_balance exposure_mode
Image Filters
| Attribute | Type | Description |
|---|---|---|
data-fg-lb-thumb-filter | CSS filter string | Filter applied to thumbnail strip items |
data-fg-lb-thumb-filter-hover | CSS filter string | Filter on thumbnail hover |
data-fg-lb-full-filter | CSS filter string | Filter applied to the main displayed item |
data-fg-lb-full-filter-hover | CSS filter string | Filter on main item hover |
Example: data-fg-lb-full-filter="grayscale(100%)" renders all items in black and white until hovered.
Info Panel REST Endpoint #
When a visitor opens an item, the Lightbox fetches extended metadata from:
GET /wp-json/fotogrids/v1/lightbox/item/{id}
Authentication: No nonce required. The request must name the item’s Gallery as gallery_id, and it follows that Gallery’s password and access settings.
Path parameter:
| Parameter | Type | Description |
|---|---|---|
id | integer | The item ID from data-fg-item-id on the trigger element |
Response shape:
{
"id": 42,
"caption": "Sunrise over the valley",
"description": "Taken at 5:43am on the eastern ridge.",
"credit": "© Jane Smith",
"file_info": {
"filename": "sunrise.jpg",
"filesize": "2.4 MB",
"width": 4000,
"height": 2667,
"mime_type": "image/jpeg"
},
"exif": {
"camera": "Canon EOS R5",
"aperture": "f/2.8",
"shutter_speed": "1/250s",
"iso": "400",
"lens": "RF 85mm f/1.2L",
"focal_length": "85mm",
"date_taken": "2025-01-12 05:43:00",
"copyright": "© Jane Smith",
"orientation": "Landscape",
"flash": "No Flash",
"white_balance": "Auto",
"exposure_mode": "Manual"
},
"tags": [
{ "id": 7, "name": "Landscape", "slug": "landscape" }
],
"people": [
{ "id": 3, "name": "Jane Smith", "slug": "jane-smith" }
],
"location": {
"name": "Eastern Ridge",
"latitude": 45.123,
"longitude": -122.456
}
}
Fields not set for an item are returned as null (scalars) or [] (arrays). The Lightbox silently skips rendering any block whose data is null or empty.
latitude and longitude are included only when the Gallery’s info panel shows the Location block. exif contains only the fields set in the Gallery’s EXIF Fields setting, and is null when the EXIF block is off.
Caching: Responses are cached in memory for the page session. Navigating back to a previously opened item shows cached data immediately without a second request.
The Lightbox Singleton #
The Lightbox is a singleton — one FotoGridsLightbox instance is created at page load and reused across all galleries on the page. It is accessible at:
window._fgLightbox // internal reference — treat as read-only
Direct manipulation of the singleton is not a supported API and may change between versions. Use the custom events above as the stable integration surface.