How to force download of image on click

I have an HTML element with this content below. It’s basically a hyperlink on an image. But when I click on the image, Chrome opens up the image in a new tab, instead of downloading it to local drive.

Replace parenthesis () with angle brackets <>
(a href=“https://myurl.com/image.jpg” download) (img src=“https://myurl.com/image.jpg”) (/a)

Is there a way to force Chrome (and other browsers) to download image instead of opening the URL?

P.S. I read this “In the latest versions of Chrome, you cannot download cross-origin files (they have to be hosted on the same domain).” - perhaps that’s the issue.

This topic was automatically closed after 70 days. New replies are no longer allowed.