我正在使用灯箱插件(https://github.com/imgix/luminous)
我有以下设置(见下文),能够为单个图像的灯箱添加标题,但我不知道如何使其适用于多个图像。我真的不想手动更改插件源代码,但如果这是唯一的方法,那就没问题了。我欢迎任何建议。谢谢。
HTML
<figure class="..." ...>
<a class="lightbox-link" href="uploads/img/small/img5449.jpg" tabindex="0">
<img class="..." src="uploads/img/small/img5449.jpg" alt="Watch" data-caption="Nunc et dui nec ex egestas aliquet sagittis ut nisl. ">
<figcaption class="caption">
<p>Sed pellentesque aliquam enim, <strong>dapibus convallis</strong> odio vestibulum eu. Nunc et dui nec ex egestas aliquet sagittis ut nisl. </p>
</figcaption>
</a>
</figure>
JAVASCRIPT
function initLuminous(options) {
let config = options || {};
let lightboxLinks = document.querySelectorAll(".lightbox-link");
if(lightboxLinks.length == 1){
if(config.caption){
config.caption = lightboxLinks[0].dataset.caption;
}
new Luminous(lightboxLinks[0], config);
}
if(lightboxLinks.length > 1){
// TODO: ADD CAPTIONS FOR MULIPLE IMAGES??
new LuminousGallery(lightboxLinks, config);
}
}
let options = {
caption: true
}
initLuminous(options);