3 year(s) ago
Just thought I'd share this customization. Looking around the forums I found bits and pieces but nothing gave me a definitive solution. So this is my "quick and dirty" way to enabled a fullscreen random background image in 2.0. IMPORTANT DISCLAIMER: Please keep in mind this modifies how the backgrounder works across all exhibits, so if you need separate backgrounds on different sections/exhibits you aren't going to want to use this. I use this method to generate a random background on my "Main" section which is hidden– the default "homepage" as it were. I do not have backgrounds on any of my exhibits, just text and image content. If I were to try and upload a background image on those exhibits they would automatically load the random background images.
That being said, I think this can be useful for people who are trying to accomplish the same functionality I am. I know there is probably a better way to do this which doesn't permanently alter the backgrounder plugin, but I'm not a big coder so please feel free to contribute if you have suggestions/improvements.
First put all your background images in a folder in your root directory. I called my "randombg".
Second, make a "random_bg.php" file with the following code:
$img_array array'bg_01.jpg' 'bg_02.jpg' 'bg_03.jpg' 'bg_04.jpg' 'bg_05.jpg' 'bg_06.jpg' 'bg_07.jpg' 'bg_08.jpg' 'bg_09.jpg' 'bg_10.jpg'
$img_rnd = rand(0, sizeof($img_array) - 1);
header('Content-Disposition: filename=' . $img_array[$img_rnd]);
Save this file in the same directory as your background images. Make sure your filenames match.
Third, modify the "plugin.backgrounder.php" file in your plugins folder. Find line 14 and change this:
$style .= ($OBJ->vars->exhibit['bgimg'] != '') ? "nbackground-image: url(" . $OBJ->baseurl . "/files/" . $OBJ->vars->exhibit['bgimg'] . ");nbackground-repeat: $tiling;nbackground-position: 215px 0;nbackground-attachment: fixed;n" : '';
$style .= ($OBJ->vars->exhibit['bgimg'] != '') ? "nbackground: url(" . $OBJ->baseurl . "/randombg/random_bg.php" . ") no-repeat center center fixed;n-moz-background-size: cover;n-webkit-background-size: cover;n-o-background-size: cover;nbackground-size: cover;n" : '';
Save and upload that.
Fourth, edit your exhibit (in my case my hidden "Main" exhibit which functions as my homepage) and upload a background. It doesn't matter what the background is, this is just to activate the plugin.backgrounder.php, the modifications to the code will point to your PHP script which calls a random image from your folder.
Bob's your uncle.