Inserting downloadable img?

5 replies
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
#downloadable #img #inserting
  • Profile picture of the author IdeaBox
    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.
    {{ DiscussionBoard.errors[8440360].message }}
    • Profile picture of the author Brandon Tanner
      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.
      Signature

      {{ DiscussionBoard.errors[8440860].message }}
  • Profile picture of the author IdeaBox
    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
    {{ DiscussionBoard.errors[8440918].message }}
    • Profile picture of the author Brandon Tanner
      Originally Posted by IdeaBox View Post

      only 11.8% of web traffic comes from IE.
      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 ).
      Signature

      {{ DiscussionBoard.errors[8441082].message }}
  • Profile picture of the author RobinInTexas
    Originally Posted by IdeaBox View Post

    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
    Many users are on corporate managed computers and have no choice due to policy restrictions. Lots of Wondoze XP/IE browsers.
    Signature

    Robin



    ...Even if you're on the right track, you'll get run over if you just set there.
    {{ DiscussionBoard.errors[8441192].message }}

Trending Topics