new ImageLightbox(document.querySelectorAll('a[data-imagelightbox="basic"]'));
Video support
Add data-ilb2-video to the link, containing the parameters of a HTML5 video tag as JSON. You can also include a sources field - a list of source tags similarily encoded.
new ImageLightbox(
document.querySelectorAll('a[data-imagelightbox="caption"]'),
{
caption: true,
},
);
With navigation
new ImageLightbox(
document.querySelectorAll('a[data-imagelightbox="navigation"]'),
{
navigation: true,
},
);
Quit behavior
new ImageLightbox(document.querySelectorAll('a[data-imagelightbox="quit"]'), {
quitOnDocClick: false,
quitOnEnd: false,
quitOnImgClick: true,
});
With history & permalinks
new ImageLightbox(
document.querySelectorAll('a[data-imagelightbox="history"]'),
{
history: true,
},
);
Open with ?imageLightboxIndex=2 added to the url to open the third image (may need to add &imageLightboxSet=history as well because there are multiple examples)
History with ids
new ImageLightbox(
document.querySelectorAll('a[data-imagelightbox="history-ids"]'),
{
history: true,
},
);
Add data-ilb2-id="img2" and open with ?imageLightboxIndex=img2 added to the url to open that image (may need to add &imageLightboxSet=history-ids as well because there are multiple examples)
Filter images by extension
Allow gif only
new ImageLightbox(
document.querySelectorAll('a[data-imagelightbox="allowedtypes"]'),
{
allowedTypes: "gif",
},
);