Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 26th Aug 2013, 01:10 PM   #1
Warrior Member
 
Join Date: 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Inserting downloadable img?
Share on: 
fb share twitter share gplus share more share

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
Elfy5555 is offline  
Unread 26th Aug 2013, 01:19 PM   #2
Dev4Hire
War Room Member
 
Join Date: 2011
Location: Missouri
Posts: 104
Thanks: 30
Thanked 30 Times in 16 Posts
Default
Re: Inserting downloadable img?
Share on: 
fb share twitter share gplus share more share

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.
IdeaBox is offline  
Unread 26th Aug 2013, 04:19 PM   #3
Advanced Warrior
War Room Member
 
Brandon Tanner's Avatar
 
Join Date: 2006
Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
Default
Re: Inserting downloadable img?
Share on: 
fb share twitter share gplus share more share

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.


Brandon Tanner is offline  
The Following User Says Thank You to Brandon Tanner For This Useful Post:
Unread 26th Aug 2013, 04:45 PM   #4
Dev4Hire
War Room Member
 
Join Date: 2011
Location: Missouri
Posts: 104
Thanks: 30
Thanked 30 Times in 16 Posts
Default
Re: Inserting downloadable img?
Share on: 
fb share twitter share gplus share more share

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
IdeaBox is offline  
Unread 26th Aug 2013, 05:58 PM   #5
Advanced Warrior
War Room Member
 
Brandon Tanner's Avatar
 
Join Date: 2006
Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
Default
Re: Inserting downloadable img?
Share on: 
fb share twitter share gplus share more share

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 ).


Brandon Tanner is offline  
The Following 2 Users Say Thank You to Brandon Tanner For This Useful Post:
Unread 26th Aug 2013, 06:42 PM   #6
ɹoıɹɹɐʍ ǝʌıʇɔɐɹǝdʎɥ
War Room Member
 
RobinInTexas's Avatar
 
Join Date: 2008
Location: Texas
Posts: 2,138
Thanks: 243
Thanked 453 Times in 382 Posts
Blog Entries: 3
Default
Re: Inserting downloadable img?
Share on: 
fb share twitter share gplus share more share

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.

Robin


...Even if you're on the right track, you'll get run over if you just set there.
RobinInTexas is offline  
Closed Thread


Bookmarks

Tags
downloadable, img, inserting


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 07:56 PM.