Hey, I'm currently using the following script to display a random set of images from a folder on my website:-
<?
$imglist='';
//$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/
// see that you don't forget about the "/" at the end
$img_folder = "gallery/thumbs/";
mt_srand((double)microtime()*1000);
//use the directory class
$imgs = dir($img_folder);
//read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners)
while ($file = $imgs->read()) {
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
$imglist .= "$file ";
} closedir($imgs->handle);
//put all images into an array
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;
//generate a random number between 0 and the number of images
$random = mt_rand(0, $no);
$image = $imglist[$random];
//display image
echo '<img src="'.$img_folder.$image.'" border=0>';
?>
Basically the problem I'm having is that some of the images in the directory are larger in physical size than others (see a list below). Heres a list of the current files:-
Filename Date Time Size
10-idea6.jpg 22-Oct-2007 11:46 9k
11-hood_forest2.jpg 26-Oct-2007 10:33 7k
12-applebox1.jpg 11-Nov-2007 11:48 7k
13-applebox2.jpg 11-Nov-2007 11:49 6k
lrg-14-finalflame.jpg 12-Nov-2007 06:07 35k
lrg-15-working.jpg 24-Nov-2007 14:56 35k
lrg-16-finala.jpg 29-Nov-2007 08:47 58k
RED = Too large, need to be filtered out
I was just wondering if I could modify the above script to filter these larger files out (and thus not displaying them ever) by either denying the name "lrg-....." or using a size limit.
Also as another point would it be possible to have the script rescale the images to a certain resolution before displaying them?
Im very new to php, any help is welcome