Placed in: Home viagra australia
viagra online
viagra sale
cialis online
cialis australia
PHP Random Image Rotation

Want some randomness on your website? Try out this PHP image rotator. This script will display a random image every time the user re-loads the page or starts navigating. A very nice effect that can help you make your website a little bit more interactive.

PHP Random Image Rotation

This script can be perfectly used for a banner of header on your website. You can also use this in your signature or avatar on a forum. Additionally, you can rotate HTML and CSS files. Just make sure this script is placed on a PHP server, otherwise it will not work.

Demo

Simply refresh the current page and see the image below changing each time. The image is chosen randomly. You can also visit the demo page Demo for a lightweight demo page.

Installing on your site

To install the script, simply download it and place it in any folder of your server. In the default configuration, all images from the folder where the script is located are used.

Example:

  1. images/header/rotate.php
  2. images/header/abstract.jpg
  3. images/header/bird.jpg
  4. images/header/butterfly.jpg
  5. images/header/happy.jpg

Now direct the source to the PHP file and you're done.

<img src="images/header/rotate.php" alt="Header" width="400" height="100" />

That's it. Now any random image file located in the same directory as the script will be displayed.

Advanced configuration

  • $folder = '.';

Change this variable in the script to locate the directory where your images are placed. When the default is selected, the script wil randomly use any image file that is located in the same directory as the script.

  •     $extList = array();
      $extList['gif'] = 'image/gif';
      $extList['jpg'] = 'image/jpeg';
      $extList['jpeg'] = 'image/jpeg';
      $extList['png'] = 'image/png';

In this variable you can set which image types are used. For example, remove all the default $extList values and add a $extList['css'] = 'text/css';. Now a random CSS file be selected. This way, you can play a little bit with your websites CSS, making it fun for the visitor every time he reloads the page. You can actually random any file you want.

Attached files:

SourceDownload Source

DemoView Demo

Enjoy and good luck using this script. Where are you going to use it for?


Tags:  php webdesign image rotate script

Interested in this topic? You might enjoy another article I've written called

Did you like this article? Subscribe to my feed or email to keep updated on new articles.

Spread the word and submit to:
Digg!Reddit!Del.icio.us!Facebook!StumbleUpon!
 
< Prev   Next >
Subscribe

Subscribe to Marcofolio