I'm providing a theme setting to define a group of images for the frontpage background. On page load, I want to pick an image at random from this pool.
My approach is to add a line of inline CSS styling the html element with the given image url like this:
<style>
html {
background: url(images/random_image_3.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
Is there a preferred way of doing this ? Should i use a localize_style function I haven't found out about, or just echo the css out using the right hook?
And what's the best hook for this, only targeting the front facing site?