<a href="https://www.joomlacontenteditor.net/path/to/image" download="" />
We have a website that will have thousands of images that we need to create downloadable links for. Entering them manually will be incredibly time-consuming.
Thank you!!
Tom
A content editor for Joomla!®
You need to be logged in to post in the forum - Log In
An active JCE Pro Subscription is required to post in the forum - Buy a Subscription
Please create a new Ticket and we will get back to you as soon as we can.
Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Latest post by tomstark1963 on Wednesday, 29 November 2023 21:06 GMT
document.addEventListener('DOMContentLoaded', (event) => {
// Select all images with .jpeg or .jpg extension
const images = document.querySelectorAll('img[src$=".jpeg"], img[src$=".jpg"]');
images.forEach(img => {
// Get the image source and the filename
const imgSrc = img.src;
const imgName = imgSrc.split('/').pop();
// Create an anchor element
const anchor = document.createElement('a');
anchor.href = imgSrc;
anchor.download = imgName;
// Wrap the image inside the anchor
img.parentNode.insertBefore(anchor, img);
anchor.appendChild(img);
});
});
You can refine selector in the querySelectorAll method to better target the images, for example if the images are in a specific folder, then you can change the selector to:
document.querySelectorAll('img[src*="/images/"][src$=".jpeg"], img[src*="/images/"][src$=".jpg"]');
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
What we would really like is to add a 'download' option to the Target dropdown list of items. Is that possible?
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Your post is being submitted…