MyBB Community Forums

Full Version: Random Logo
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Anyone knows how to make a random Logo?
And also that make "cache" of the images for save Bandwith...
You need a script that will randomly pick images like the one mark.m and matt use for there avatars.
This should work.
<?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.
if you want php to just return the filename of a random .jpg picture (to use with img source tag or so)...
$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