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.
How to download a image on link click instead of opening it
You can use JS to add download attribute to a HTML element:
element.setAttribute('download','')
Or even simpler:
element.download=''
So, you can easily add this for each link with a href
ending .jpg
:
const links=document.querySelectorAll('a[href$=".jpg"]')
links.forEach(link=>link.download='')
Try to download image from image URL, but I get HTML instead
In your "Accept" header you are not specifying any graphic formats.
A properly configured web server should send you a representation of the resource in one of the formats you accept.
Try looking at the request headers sent from your browser (use the Developer Tools - see your browser's help for how to access them). It will be accepting graphic formats as well as text.
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.
Related Topics
Change Color of Png Image Via Css
Equal Height Rows in a Flex Container
Base64 Encoded Images in Email Signatures
How to Create Uneven Rounded Sides on a Div
Positions Fixed Doesn't Work When Using -Webkit-Transform
Add Border-Bottom to Table Row ≪Tr≫
How to Display an Unordered List in Two Columns
Why Is It a Bad Thing to Have Multiple HTML Elements With the Same Id Attribute
Border Curved CSS - Circle With Curved End
:Last-Child Not Working as Expected
Difference Between HTML Div and Span Elements
Equal Width Flex Items Even After They Wrap
Height: 100% or Min-Height: 100% For HTML and Body Elements
Bootstrap Full-Width With 2 Different Backgrounds (And 2 Columns)
Input Type="Submit" VS Button Tag Are They Interchangeable
How to Strip HTML Tags from a String in SQL Server
How to Change the Height of a ≪Br≫
Why Is 'Position: Sticky' Not Working With Core Ui'S Bootstrap Css