Lightbox

A full-screen overlay image viewer. Supports keyboard navigation ( / to navigate, Esc to close), click-backdrop-to-close, and can be opened programmatically. Can be pre-populated from PHP or supplied at open-time via JavaScript.

Standalone Lightbox

A lightbox pre-loaded with six Unsplash images. Click any thumbnail below to open it at that image.

Mountain peaks at sunset Forest mist at dawn Waterfall in tropical forest Tropical beach shoreline Desert sand dunes Northern lights over snow
Click a thumbnail to open the lightbox...
PHP

Single Image Lightbox

A lightbox can hold a single image — navigation arrows are hidden automatically. Useful for enlarging a single photo or diagram.

PHP

PHP PHP Methods (Fluent)

Method / PropertyParametersDescription
$m->lightbox($id)LightboxCreate a Lightbox component.
->addImage($src, $caption, $thumb)selfPre-populate with an image. $caption and $thumb are optional.

JS JS Methods

Method / PropertyParametersDescription
m.lightbox(id)objectInitialise (or retrieve) lightbox instance.
lb.show(index, images)Open at index. images is an optional [{src, caption}] array that overrides pre-loaded images.
lb.hide()Close the lightbox.
lb.prev()Go to previous image.
lb.next()Go to next image.
lb.getIndex()numberReturn the current image index.

EVENT Events

Event NameDetailDescription
m:lightbox:open{ index }Fired when the lightbox opens.
m:lightbox:close{}Fired when the lightbox closes.
m:lightbox:change{ index }Fired when the active image changes.