website/js/imgPreview.js

14 lines
442 B
JavaScript
Raw Normal View History

2021-03-24 23:16:31 +01:00
import * as basicLightbox from 'basiclightbox'
2021-03-24 23:19:18 +01:00
let images = document.querySelectorAll("img, .clickSpan");
for(let i = 0; i < images.length; i++){
2021-03-24 22:18:55 +01:00
let element = images[i];
2021-02-28 11:25:49 +01:00
if(!(element.getAttribute("data-noPreview") === "true")) {
2021-03-24 23:16:31 +01:00
element.onclick = () => {
const instance = basicLightbox.create(`
2021-03-24 23:19:18 +01:00
<img src="${element.getAttribute("src")}">
2021-03-24 23:16:31 +01:00
`);
2021-03-24 23:19:18 +01:00
instance.show();
2021-03-24 23:16:31 +01:00
}
}
}