I have a question regarding html and js.
I want to make all pictures in <img> tags openable in a new tab without setting up manually a href link for every image. My problem is that I have over 17.000 Pictures on my website and it would be very laborious to do this for every single image. So basically every src link should be set to the href link for the <img> tag.
Is there any possibility to realize that ?
Thank you in advance!
Yeah, haven't tested it (im on mobile) but something like this:
const gallery = document.querySelectorAll(img)
gallery.forEach(image => {
let src = image.getAttribute('src')
image.addEventListener('click', function () {
window.open(src)
}
}
Once it's done add img { cursor: pointer } to your css to tell users they can click on it
You'd be better of with a script changing your images to links, and don't forget lazy load