The Lightbox widget implements a commonly-seen interface convention whereby images can be clicked to view them at a larger size inside a popup that appears on the page. In addition, related images are grouped so that they can be scrolled through inside the popup. IPS4's lightbox also supports built-in commenting.
A lightbox can be initialized on a single image as simply as:
<img src='http://url/to/image' data-ipsLightbox>
However, it's likely additional functionality would be desired. A common practice is to link to a large image but display a small thumb image on the page. In this situation, the lightbox is initialized on the link:
<a href='http://url/to/image' data-ipsLightbox><img src='http://url/to/thumb'></a>
In both of the above example, a single image will be displayed in the lightbox. It's also possible to group images together - such as in a photo album, or a group of images for a single content item. In this case, you should initialize a lightbox on all of the items, and include the group option which should be consistent between them:
<a href='http://url/to/image1' data-ipsLightbox data-ipsLightbox-group='example'><img src='http://url/to/thumb1'></a> <a href='http://url/to/image2' data-ipsLightbox data-ipsLightbox-group='example'><img src='http://url/to/thumb2'></a> <a href='http://url/to/image3' data-ipsLightbox data-ipsLightbox-group='example'><img src='http://url/to/thumb3'></a>
If provided, the widget will display other images from the same group in the lightbox.
By default, the full size image will be loaded from the href attribute on the a tag. If this option is provided, the full size image will instead be loaded from this URL.
(String; optional; default ipsLightbox)
Allows you to provide a classname prefix which will be used when the lightbox UI is built, enabling a custom UI to be shown.
(Boolean; optional; default true)
Determines whether images in the lightbox should be preloaded when the lightbox is opened, designed to reduce wait time for the user as they scroll through images.
Events emitted by ips.ui.lightbox
Triggered when the lightbox shows a new image.
Reference to this image's widget element (may different from <em>imageElem</em> if a link launches the lightbox)
Reference to the actual image element
URL to the fullsize image
URL to the image that already existed on the page (e.g. a thumbnail)
The meta information for the image, if any
Reference to the widget element that originally opened the lightbox, which may or may not be the image being viewed.