2010-02-03, 02:35 PM
2010-02-06, 07:01 AM
You need a script that will randomly pick images like the one mark.m and matt use for there avatars.
2010-02-06, 07:06 PM
This should work.
http://www.totallyphp.co.uk/scripts/random_image.htm
Need any more help, reply.
<?php
/*
* Name your images 1.jpg, 2.jpg etc.
*
* Add this line to your page where you want the images to
* appear: <?php include "randomimage.php"; ?>
*/
// Change this to the total number of images in the folder
$total = "11";
// Change to the type of files to use eg. .jpg or .gif
$file_type = ".jpg";
// Change to the location of the folder containing the images
$image_folder = "images/random";
// You do not need to edit below this line
$start = "1";
$random = mt_rand($start, $total);
$image_name = $random . $file_type;
echo "<img src=\"$image_folder/$image_name\" alt=\"$image_name\" />";
?>
http://www.totallyphp.co.uk/scripts/random_image.htm
Need any more help, reply.
2010-02-09, 12:38 AM
if you want php to just return the filename of a random .jpg picture (to use with img source tag or so)...
if you want php to directly output a random picture, very well useable with mybb directly (call the .PHP directly as a source for image in CSS foe example)
both are blazing fast
$arrayofpics = glob("/www/htdocs/XXX/images_pool/*.jpg");
$thechoice= $arrayofpics[array_rand($arrayofpics, 1)];
echo $bodytag = str_ireplace("/www/htdocs/XXX/images_pool/", "http://yourdomain/images_pool/", $thechoice);
if you want php to directly output a random picture, very well useable with mybb directly (call the .PHP directly as a source for image in CSS foe example)
$arrayofpics = glob("/www/htdocs/XXX/images_pool/*.jpg");
$thechoice= $arrayofpics[array_rand($arrayofpics, 1)];
$urlcreate = str_ireplace("/www/htdocs/XXX/images_pool/", "http://yourdomain/images_pool/", $thechoice);
Header("Content-type:Image/jpeg");
readfile($thechoice);
both are blazing fast