This will display a random image from a pre-defined list of images
Credit for this code goes to Kristin of Dragonflied.com
Step 1:
Create a folder/directory called "random" in your theme's images directory and place all the images you want in there.
For example the path you'll be using to call your random images will be: yourtheme/images/random/01.jpg
Step 2:
In yourtheme/theme.php, add the following 2 variables ($array and $image) and add the 'RAND_IMG' var to assign_vars block
| Code:: |
// random image at top in header
$array = array('01.jpg', '02.jpg', '03.jpg');
$image = rand(0, count($array)-1);
$cpgtpl->assign_vars(array(
'RAND_IMG' => $array[$image],
|
Don't forget to specify the image filenames you want in the array. Replace 01.jpg etc... with your images.
Step 3:
In yourtheme/template/header.html (or whatever template file you want to have a rotating image use the following code.
| Code:: |
<img src="{THEME_PATH}/images/random/{RAND_IMG}" alt="" border="0" /> |