Display Random images

Yesterday I came across this excellent tutorial to display Random Images. I also tried it and implemented it on this site.

1. I use bluemarine theme for this site. I created a folder "images" and uploaded three images in there.

themes/bluemarine/images
header_1.jpg
header_2.jpg
header_3.jpg

2. Modified "page.tpl.php" and added the following code

<img src="/themes/bluemarine/images/header_<?php echo(rand(1,3)); ?>.jpg" alt="Ravi Sagar" / id="random_header">

3. Modified "style.css" and add section to handle "random_header"

#random_header {
  float: left;
  width: 900px;
  height: 170px;
}

Thats it! it is simple and it looks good. Now every time page is refreshed a new Image is displayed!!

Comments

Thanks for the tip. It is simple enough to implement.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • E-Mail addresses are hidden with reCAPTCHA Mailhide.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions. Please don't mind guys!