Created
October 8, 2014 16:48
-
-
Save kevin-ashton/99cef1e876376e735128 to your computer and use it in GitHub Desktop.
Bearify (replace all images with images of bears)
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
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