Hello,
I just enhanced the snippet a bit with generating the alt attribute by a page variable and defining the folder to retrieve images from not in the snippet, but in the snippet call:
<?php
$i = 0;
$imgDir = opendir ($folder);
while ( $file = readdir( $imgDir ) )
{
//checks that file is an image
$file_type = strrchr( $file, "." );
$is_image = eregi( "jpg|gif",$file_type );
if ( $file != '.' && $file != '..' && $is_image && substr($file,1,5)!='thumb')
{ $images[$i++] = $file; }
}
closedir ($imgDir);
srand( (double) microtime()*1000000 );
$image_name = $folder . '/' . $images[rand( 0,sizeof( $images ) -1 )];
$imgSize = GetImageSize( $image_name );
//ends script if no images found
if ( $i == 0 )
die();
return( "<img src=\"" . $image_name . "\"" . $imgSize[3] . " alt=\"[*pagetitle*]\" />\n" );
?>
Please note the alt-Attribute generated by the page title (may be something else of course, even a variable that you pass to the snippet as a parameter in the snippet call like the folder parameter/variable). I removed the first line "$folder = ’directory to folder here’;" as when calling the snippet, I wrote
[!randomImage? &folder=`assets/images/random`!]
That’s working for me, in .9.6.1p2