ImageViewer

A media gallery with a main display stage and a navigable thumbnail strip. Supports images, direct video files, and YouTube links. Two layouts are available: side (default — vertical thumbnail strip on the left) and below (horizontal strip beneath the main image). Optional auto-advance, forward/back arrows, and lightbox integration are included. When navigating to a YouTube item the caption automatically fetches and displays a Video Credit link to the video's channel via the YouTube oEmbed API.

Side Layout (Default)

Thumbnails appear in a scrollable vertical strip on the left. This is the default layout — no ->layout() call is needed. Clicking the main image opens it in a lightbox.

Mountain peaks at sunset
Forest mist at dawn
Waterfall in tropical forest
Tropical beach shoreline
Desert sand dunes
Northern lights over snow
Rick Astley – Never Gonna Give You Up
Mountain peaks at sunset
Forest mist at dawn
Waterfall in tropical forest
Tropical beach shoreline
Desert sand dunes
Northern lights over snow
Mountain peaks at sunset
1 / 7
Navigate to see output...
PHP

Below Layout

Thumbnails appear in a scrollable horizontal strip below the main image. Use ->layout(\'below\') to enable this mode.

Mountain peaks at sunset
Forest mist at dawn
Waterfall in tropical forest
Tropical beach shoreline
Desert sand dunes
Northern lights over snow
Rick Astley – Never Gonna Give You Up
Mountain peaks at sunset
Forest mist at dawn
Waterfall in tropical forest
Tropical beach shoreline
Desert sand dunes
Northern lights over snow
Mountain peaks at sunset
1 / 7
PHP

Auto-Advance

Enable auto-advance with ->autoAdvance() (default: off). The interval defaults to 4 000 ms and can be changed with ->interval($ms). Clicking a thumbnail or navigation arrow resets the timer.

Mountain peaks at sunset
Forest mist at dawn
Waterfall in tropical forest
Tropical beach shoreline
Desert sand dunes
Northern lights over snow
Mountain peaks at sunset
Forest mist at dawn
Waterfall in tropical forest
Tropical beach shoreline
Desert sand dunes
Northern lights over snow
Mountain peaks at sunset
1 / 6
PHP

Custom Thumbnail Size

Use ->thumbSize($width, $height) to control thumbnail dimensions (any CSS length). Default is 80px × 60px.

Mountain peaks at sunset
Forest mist at dawn
Waterfall in tropical forest
Tropical beach shoreline
Mountain peaks at sunset
Forest mist at dawn
Waterfall in tropical forest
Tropical beach shoreline
Mountain peaks at sunset
1 / 4
PHP

With Direct Video

Pass a direct video URL (MP4, WebM, etc.) to ->addVideo() to embed a native HTML video player as one of the gallery items. A custom thumbnail image can be provided as the third parameter.

Mountain peaks at sunset
Forest mist at dawn
Waterfall in tropical forest
Big Buck Bunny (CC)
Mountain peaks at sunset
Forest mist at dawn
Waterfall in tropical forest
Mountain peaks at sunset
1 / 4
PHP

PHP PHP Methods (Fluent)

Method / PropertyParametersDescription
$m->imageViewer($id)ImageViewerCreate an ImageViewer component.
->layout($layout)selfSet thumbnail strip position: 'side' (default) or 'below'.
->addImage($src, $thumb, $caption)selfAdd an image. $thumb defaults to $src; $caption is optional.
->addVideo($src, $caption, $thumb)selfAdd a video. Accepts a direct URL or YouTube share/watch link. Auto-derives YouTube thumbnail when $thumb is omitted.
->lightbox($enabled, $lightboxId)selfEnable lightbox on main-image click. Default: false. Omit $lightboxId to auto-generate a sibling Lightbox.
->autoAdvance($enabled)selfEnable auto-advance slideshow on init. Default: false.
->interval($ms)selfAuto-advance interval in milliseconds. Default: 4000.
->height($height)selfStage height (any CSS length, e.g. '400px', '50vh'). Default: 380px.
->thumbSize($width, $height)selfThumbnail dimensions (any CSS length). Default: 80px, 60px.

JS JS Methods

Method / PropertyParametersDescription
m.imageviewer(id)objectInitialise (or retrieve) ImageViewer instance.
iv.goTo(index)Navigate to item at index.
iv.prev()Go to previous item.
iv.next()Go to next item.
iv.currentIndex()numberReturn the active item index.
iv.startAuto()Start auto-advance.
iv.stopAuto()Stop auto-advance.

EVENT Events

Event NameDetailDescription
m:imageviewer:change{ index }Fired after the active item changes.