Are you only interested in CSS background image? This can be done by loading the image and shifting it using CSS.
Will one of these examples work?
HTML
<body id="page-body"> <img class="bg" src="images/bodyBackground1.jpg"> <div class="wrapper"> </div> </body>
CSS
html { background: url(images/bodyBackground1.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } body { background:#fff; margin: 0; padding: 0; overflow:hidden; } html, body { height: 100%; } img.bg { min-height: 100%; min-width: 1024px; width: 100%; height: auto; position: fixed; top: 0; left: 0; } @media screen and (max-width: 1024px) { img.bg { left: 50%; margin-left: -512px; } }
Or this one? It loads images from the database into an array and loads them at random, but you can get information from this:
PHP load function
<?php $bg_images = array( 0 => 'comp1.png', 1 => 'comp2.png', 2 => 'comp3.png', .... ); $image = $bg_images[ rand(0,(count($bg_images)-1)) ]; $showBG = "<img class=\"source-image\" src=\"images/bg/" . $image . "\"/>"; ?>
HTML
... <body> <?php echo $showBG; ?> <div id="wrapper"> ...
CSS
html, body { margin:0; height:100%; } img.source-image { width:100%; position:absolute; top:0; left:0; z-index:0; min-width:1024px; }
These options should fill the browser window according to the height and width.
source share