Fix errors in lightbox controller

This commit is contained in:
Björn Fromme
2021-08-24 11:21:52 +02:00
parent ee7f17c720
commit 28a19ce504
@@ -17,8 +17,12 @@ export default class extends Controller {
elements.push(element)
} else {
this.thumbTargets.forEach(thumb => {
let caption = element.hasAttribute('data-lightbox-caption') ? element.dataset.lightboxCaption : null
elements.push({ href: thumb.href, title: caption })
let element = { href: thumb.href }
let caption = this.element.hasAttribute('data-lightbox-caption') ? this.element.dataset.lightboxCaption : null
if (null !== caption) {
element.title = caption
}
elements.push(element)
})
}
this.lightbox = Glightbox({