Skip to content

Instantly share code, notes, and snippets.

@ericvicenti
Created April 14, 2014 06:00
Show Gist options
  • Save ericvicenti/10620006 to your computer and use it in GitHub Desktop.
Save ericvicenti/10620006 to your computer and use it in GitHub Desktop.
browser-side check url for image
module.exports = function checkUrlForImage(url, cb) {
var doc = window.document;
var img = doc.createElement('img');
img.onload = function() { cb(true); }
img.onerror = function() { cb(false); }
img.setAttribute('src', url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment