Skip to content

Instantly share code, notes, and snippets.

@kevin-ashton
Created October 8, 2014 16:48
Show Gist options
  • Save kevin-ashton/99cef1e876376e735128 to your computer and use it in GitHub Desktop.
Save kevin-ashton/99cef1e876376e735128 to your computer and use it in GitHub Desktop.
Bearify (replace all images with images of bears)
var jQueryScriptOutputted = false;
function initJQuery() {
//if the jQuery object isn't available
if (typeof(jQuery) == 'undefined') {
if (! jQueryScriptOutputted) {
//only output the script once..
jQueryScriptOutputted = true;
//output the script (load it from google api)
document.write("<script type='text/javascript' src='https://code.jquery.com/jquery-2.1.1.min.js'></script>");
}
setTimeout("initJQuery()", 50);
} else {
$(function() {
$("img").each(function(){
var img = $(this),
h = img.height(),
w = img.width();
img.attr("src", "http://placebear.com/g/" + w + "/" + h);
});
});
}
}
initJQuery();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment