0)
{
$imageNumber = (time()+(microtime()*1000000)) % count($fileList);
$img = $folder.$fileList[$imageNumber];
$filename = $fileList[$imageNumber];
}
#Check if user has specified ID-tag
if (isset($params['id']))
{
$id = " id="".$params['id'].""";
} else {
$id = "";
}
#Check if user has specified ALT-tag, otherwise use default (image file name)
if (isset($params['alt']))
{
$alt = " alt="".$params['alt'].""";
} else {
$alt = " alt="".$filename.""";
}
#Check if user has specified image height, otherwise use default
if (isset($params['height']))
{
$height = " height="".$params['height'].""";
} else {
$height = "";
}
#Check if user has specified image width, otherwise use default
if (isset($params['width']))
{
$width = " width="".$params['width'].""";
} else {
$width = "";
}
#Check if user has specified image alignment, otherwise use default
if (isset($params['align']))
{
$align = " align="".$params['align'].""";
} else {
$align = "";
}
return "";
}
function smarty_cms_help_function_random_image() {
?>
What does this do?
Shows a random image.
How do I use it?
Just insert the tag into your template/page like: {random_image}
What parameters does it take?
(optional) folder - ("
http://www.scotwellhouse.com/uploads/im ... m/img1.jpg").
(optional) height - Image height (579px).
(optional) width - Image width (default is unspecified, eg. actual image width).
(optional) align - Image alignment (default is unspecified).
(optional) alt - Image description/mouse-over text (default is image file name).
(optional) id - Image id (default is unspecified).
Hints and Tips
-A good idea might be to organize your random images in folders (ex): uploads/images/random/pagename/ a.s.o.
-Specifying width and not height (or viceversa) prohibits your images from exceeding that certain width (or height). Pretty useful sometimes.
-Thumbnail images are automatically excluded (images starting with "thumb_")
Author: Anders Hansen <
baconburgare@hotmail.com>
Thanks to Greg for hinting on the ID-tag
Version: 1.2
Change History:
1.0a - Alpha version released.
1.0 - Added ALT-tag. Changed default values for Height, Width and Align
1.1 - Images starting with "thumb_" (thumbnails) prevented from being displayed
1.2 - Added ID-tag and changed IMG tag to comply with W3C standard. Also fixed a bug where the same image was selected when you had several random images on the same page.