Last active
January 22, 2018 21:36
-
-
Save mmore500/16028ad7d88829d1d9c1e87d0fa04fbc to your computer and use it in GitHub Desktop.
excerpt from my Jekyll site
This file contains 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
<script type="text/javascript"> | |
images_list= {{ site.data.images | jsonify }} | |
console.log(images_list) | |
function getImageHTML() { | |
var html_code = '<img src=\"'; | |
var randomIndex = Math.floor(Math.random() * images_list.length); | |
html_code += images_list[randomIndex]["href"]; | |
html_code += '\" style=\"max-width:90vw; max-height:60vh;\" alt=\"have you tried ~refreshing~?!\"/>'; | |
html_code += "<br /><p align=\"left\">" | |
html_code += images_list[randomIndex]["caption"]; | |
html_code += "</p>" | |
return html_code; | |
} | |
</script> | |
<div style="text-align:center"> | |
<div style="display: inline-block;"> | |
<script type="text/javascript"> | |
document.write(getImageHTML()); | |
</script> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment