2

How can I trigger a "Save Image As" action when an image is clicked?

Satpal
  • 129,808
  • 12
  • 152
  • 166
Dmytro Vasin
  • 813
  • 2
  • 11
  • 22

1 Answers1

10

You can do it using HTML5's download attribute and no jQuery with:

<a href="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" download>
    <img src="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" alt="Smiley face">
</a>

You can also declare the filename if you would like it to take a name other than default:

<a href="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" download="fileName.jpg">
    <img src="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" alt="Smiley face">
</a>
skrilled
  • 5,242
  • 2
  • 23
  • 47
j08691
  • 197,815
  • 30
  • 248
  • 265