Last active
January 27, 2016 03:25
-
-
Save warrendodsworth/d0a97b0e20ddc2457760 to your computer and use it in GitHub Desktop.
Download specific images off a webpage using JQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Incomplete | |
| $('div a.grid-image').map(function (i, link){ | |
| $('body').append('<canvas/>'); | |
| var canvas = $('canvas')[i]; | |
| var ctx = canvas.getContext('2d'); | |
| var img = new Image(); | |
| img.crossOrigin = 'anonymous'; | |
| img.src = '...'; | |
| img.onload = function(){ | |
| ctx.drawImage(img, 0, 0); | |
| }; | |
| img.src = link.href; | |
| var filename = $(link).attr('title'); | |
| link.href = img.src; | |
| link.download = filename + '.png'; | |
| link.click(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Works in Chrome - but chrome ignores the download filename | |
| $('div a.grid-image').map(function (i, link){ | |
| var title = $(link).attr('title'); | |
| link.download = title + ".png"; | |
| link.click(); | |
| }); | |
Author
Sry mate, haven't seen that before, you may be able to use a chrome extension to do it, but link from within a website. You'd need access to the browsers api
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
How can i create website shortcut, on user desktop by clicking a link in website.
means in website we will give image link, if the user clicks on the link, it has to create a shortcut of a website on user desktop.