Skip to content
Snippets Groups Projects
Verified Commit b2efb92a authored by Jonas Leder's avatar Jonas Leder
Browse files

open preview when clicking on image

parent fc75c074
No related branches found
No related tags found
No related merge requests found
import * as basicLightbox from 'basiclightbox'
class CustomImage extends HTMLElement {
async connectedCallback(){
const originalURL = new URL(this.getAttribute("src"), document.baseURI).href;
......@@ -28,6 +30,16 @@ class CustomImage extends HTMLElement {
image.setAttribute("loading", "lazy");
image.setAttribute("original-src", originalURL);
this.appendChild(image);
if(!(this.getAttribute("data-noPreview") === "true")) {
image.onclick = () => {
const instance = basicLightbox.create(`
<img src="${originalURL}">
`);
instance.show();
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment