Skip to content

Instantly share code, notes, and snippets.

@warrendodsworth
Last active January 27, 2016 03:25
Show Gist options
  • Select an option

  • Save warrendodsworth/d0a97b0e20ddc2457760 to your computer and use it in GitHub Desktop.

Select an option

Save warrendodsworth/d0a97b0e20ddc2457760 to your computer and use it in GitHub Desktop.
Download specific images off a webpage using JQuery
//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();
});
//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();
});
@ManjunathRJogar
Copy link

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.

@warrendodsworth
Copy link
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