Force Browser to Download Image Files on Click

href image link download on click

<a download="custom-filename.jpg" href="/path/to/image" title="ImageName">
<img alt="ImageName" src="/path/to/image">
</a>

It's not yet fully supported caniuse, but you can use with modernizr (under Non-core detects) to check the support of the browser.

Force Browser to download Image with Javascript window.open?

Use application/octet-stream instead of image/jpg:

If [the Content-Disposition] header is used in a response with the application/octet-stream content-type, the implied suggestion is that the user agent should not display the response, but directly enter a `save response as...' dialog.

— RFC 2616 – 19.5.1 Content-Disposition



Related Topics



Leave a reply



Submit