2

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

Satpal
  • 132,252
  • 13
  • 159
  • 168
Dmytro Vasin
  • 823
  • 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,350
  • 2
  • 26
  • 48
j08691
  • 204,283
  • 31
  • 260
  • 272