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.
Click a thumbnail to open the lightbox...
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 Methods (Fluent)
| Method / Property | Parameters | Description |
|---|---|---|
$m->lightbox($id) | Lightbox | Create a Lightbox component. |
->addImage($src, $caption, $thumb) | self | Pre-populate with an image. $caption and $thumb are optional. |
JS JS Methods
| Method / Property | Parameters | Description |
|---|---|---|
m.lightbox(id) | object | Initialise (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() | number | Return the current image index. |
EVENT Events
| Event Name | Detail | Description |
|---|---|---|
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. |