Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Random Image Display (Read 2335 times)
CanaryWoolf
New Member
*
Offline


Check out www.bamzooki.or
g.uk

Posts: 2
Joined: Feb 14th, 2006
Gender: Male
Random Image Display
Feb 14th, 2006 at 8:47pm
Print Post  
Hi, first post so go steady on me.

I've included a simple script on my yabb 2.1 board :
http://www.bamzooki.org.uk/cgi-bin/yabb2/YaBB.pl
that displays a random image on refresh or page load.

It's quite simple but make the site appear more dynamic.

Make a new cgi file (call it random_image.cgi) in your cgi-bin and use this code:

Code
Select All
#!/usr/bin/perl
# location of Perl (above) - check your doc or ask admin

##### SETTABLE VARIABLES ####################################

# URL of the location of your images
$imagedir = 'http://www.yourwebsite.com/yabbfiles/Templates/Forum/default/';

# Name of the image files that you want to use
@arrimages = ("image1.jpg", "image2.jpg", "image3.jpg");

##### END OF SETTABLE VARIABLES ####################################


# Randomize
$seedno = $#arrimages + 1;
srand(time ^ $$);
$imageid = rand($seedno);
print qq(Location: $imagedir$arrimages[$imageid]\n\n);
return;

##### End of Script ######################################## 



Then in place of the image where you want the image diplayed (Iused it in the yabb template in the header area) use this:

Code
Select All
<img src="http://www.yourwebsite.com/cgi-bin/random_image.cgi"> 



Good luck

  

BAMZOOKi - Do you know what it is yet?

www.bamzooki.org.uk
Back to top
WWW  
IP Logged
 
Namster
New Member
*
Offline


GTN

Posts: 36
Location: Aichi
Joined: Jul 27th, 2006
Gender: Male
Re: Random Image Display
Reply #1 - Feb 26th, 2008 at 10:04am
Print Post  
Thanks, this was exactly what I was looking for to randomize a picture on my template. Smiley
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint