0

I want to download a .jpg link when the link is clicked, I've seen some answers here that I should only add the download="image.jpg" but it only opens the image link and not downloading it. I guess it only works if the image is already on my folder file (which is pointless in my case) and not in external link like that I've provided?

<a href="https://i.imgur.com/IskAzqA.jpg" download="image.jpg">
Download
</a>

Is there solution for this? I don't mind using Jquery or PHP

freedomn-m
  • 27,664
  • 8
  • 35
  • 57
  • 1
    Correct, the `download` attribute only works for same origin content (or blob/data URIs.) jQuery will likely not help much, because I'd assume that an image from that service is probably _not_ CORS enabled; in which case only a server-side solution is possible. – CBroe Jan 30 '23 at 13:37
  • [MDN a#download](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download) – freedomn-m Jan 30 '23 at 13:38
  • `$.get` / `fetch()` the image then provide it as a data: blob to a url – freedomn-m Jan 30 '23 at 13:39
  • 1
    This solution works fine for your image on jsfiddle: https://stackoverflow.com/a/73985323/2181514 – freedomn-m Jan 30 '23 at 13:43

0 Answers0