electerious / basicLightbox

The lightest lightbox ever made.

Home Page:https://basiclightbox.electerious.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lightbox from attributed elements not possible out of the box?

jenstornell opened this issue · comments

Let's say I have 30 images in my content and I want to show them in a lightbox.

Then I would prefer something like this:

const instance = basicLightbox.create({
  selector: 'img.lightbox'
});

Something like above would then find all the images that has the class lightbox and then create a lightbox for all of them.

That's not possible today?

That's not possible, but you can achieve almost the same with a loop:

document.querySelectorAll('img.lightbox').forEach((img) => {
  const instance = basicLightbox.create(img);
})