Looking for some general JS guidance here. I’m wanting to make it so uploaded images in summernote using Wapplers summernote upload plugin open in a lightbox. So essentially, I need to modify summernote-uload.js so it wraps the URL it inserts by default in an anchor.
I’ve looked in the file, but I’m not really sure where to start. Anyone does this before?
After getting nowhere with editing the js file, I decided to instead try making all images on the page open in a lightbox instead as that works for me. After some further messing around:
You can insert the following JS on a page to wrap images in an anchor:
function wrapImages() {
$('img:not([data-nolink])').each(function() { //Iterate through each img element
$(this).wrap('<a href="' + $(this).attr('src') + '" dmx-lightbox:lightbox="" >'); //Wrap with link to own src
});
}
The problem is this doesn’t seem to open in a lightbox, because I’m guessing something runs in the background of Wappler to specify which images should open in a lightbox, and as this is client side, it doesn’t run.