Skip to content

Instantly share code, notes, and snippets.

@jpjuliao
Created April 9, 2020 20:56
Show Gist options
  • Save jpjuliao/a0415af71248f35b1a56dfb6e59712ca to your computer and use it in GitHub Desktop.
Save jpjuliao/a0415af71248f35b1a56dfb6e59712ca to your computer and use it in GitHub Desktop.
HTML element to image via JS
// jQuery.getScript('https://github.com/tsayen/dom-to-image/blob/master/dist/dom-to-image.min.js');
// jQuery.getScript('https://raw.githubusercontent.com/eligrey/FileSaver.js/master/dist/FileSaver.min.js');
(function($){
function download(elem) {
domtoimage.toBlob(
elem,
{
height: 343.47,
width: 343.47,
}
).then(function(blob) {
window.saveAs(blob, "my-node.jpeg");
});
}
$('.uabb-photo-gallery-content.chs, .uabb-photo-gallery-content.reba').each(function(i, elem){
// if (i > 5) return;
// if (i < 15 && i > 20) return;
download( elem );
});
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment