Skip to content

Instantly share code, notes, and snippets.

@porty
Last active August 29, 2015 13:56
Show Gist options
  • Save porty/9064813 to your computer and use it in GitHub Desktop.
Save porty/9064813 to your computer and use it in GitHub Desktop.
Show me an image plz
<html>
<head>
<style>
body {
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
</style>
<script>
<!--
function getQueryParams(qs) {
qs = qs.split("+").join(" ");
var params = {}
var tokens = null;
var re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])]
= decodeURIComponent(tokens[2]);
}
return params;
}
function setPicture() {
var params = getQueryParams(document.location.search);
var img = params.img;
var color = params.color || "black";
var size = params.size || "contain";
document.body.style["background-image"] = "url(" + img + ")";
document.body.style["background-color"] = color;
document.body.style["background-size"] = size;
}
//-->
</script>
</head>
<body onload="setPicture();">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment