Inserting downloadable img?

by 5 replies
7
Hello, I was wondering if anyone knew how I could create a downloadable img link? I'm working on a website and when a person clicks the download button I would like it to download the image they clicked to their computer. How would I do this? If anyone could explain or give me some coad examples I would really appreciate it.



Thanks
#programming #downloadable #img #inserting
  • Code:
    <a href="/path/to/image" download="imagename"><img src="/path/to/image" /></a>

    Example

    Code:
    <a href="http://upload.wikimedia.org/wikipedia/commons/3/3f/Stephenson%27s_Rocket_drawing.jpg" download="myimage"><img src="http://upload.wikimedia.org/wikipedia/commons/3/3f/Stephenson%27s_Rocket_drawing.jpg" /></a>
    Suppose I should mention that the download="myfilename" will be the name of the downloaded file. The extension WILL be auto added.
    • [1] reply
    • FYI... the "download" attribute is not supported in IE and a few other browsers (see this for compatibility). So if you want a cross-browser solution, the easiest way is to just put the image in a zip file, and link to that.

      Or use Modernizr if you want the "download" attribute to work in all browsers...
      Modernizr Download Builder

      There are a few other ways to force downloading of images (via htaccess or php), but they are more complicated than the above 2 options.
      • [ 1 ] Thanks
  • That's true. However, only 11.8% of web traffic comes from IE. And IE 11 DOES support the download tag. If the user is using IE (and I hope nobody does) they should be updated to 11. God knows M$ pushes those updates on you until you fold.

    Stat via w3schools
    • [1] reply
    • Only 11.8% of W3School's traffic comes from IE. My own stats show a roughly similar figure for my internet marketing & tech-related sites, but for some of my sites in other niches, IE visitors still account for over 20% of the overall traffic. And the vast majority of them are not on IE11... most are on 8/9/10.

      I don't like IE any more than you do, but IMO there are still way too many IE users out there to ignore them (especially when they are clicking on the "buy" button ).
      • [ 2 ] Thanks
  • Many users are on corporate managed computers and have no choice due to policy restrictions. Lots of Wondoze XP/IE browsers.

Next Topics on Trending Feed

  • 7

    Hello, I was wondering if anyone knew how I could create a downloadable img link? I'm working on a website and when a person clicks the download button I would like it to download the image they clicked to their computer. How would I do this? If anyone could explain or give me some coad examples I would really appreciate it.