Skip to content

Instantly share code, notes, and snippets.

@mmore500
Last active January 22, 2018 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmore500/16028ad7d88829d1d9c1e87d0fa04fbc to your computer and use it in GitHub Desktop.
Save mmore500/16028ad7d88829d1d9c1e87d0fa04fbc to your computer and use it in GitHub Desktop.
excerpt from my Jekyll site
<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