free hit counters
If you are using Internet Explorer as your browser please be running at least IE 7 or above. This site does not support IE 6 or below. Go here for the latest free version including easy download and installation instructions If you want to make it real easy on yourself, download Firefox , the most popular browser in the world. It's free and simple. You'll be so glad you did.
Apr
27
2009

Really easy way to have random rotating images

You can have random rotating images in your multimedia box, feature box, widgets, or if you really want to have freedom, you can learn how to make your own custom multimedia box and place them in it.

We’re going to rotate the images with a little php code. In order to do this we need to first prepare the images to be rotated by renaming them. Get all the images to be rotated and rename them with numbers. This works with png, jpg, gif, tiff, etc. For example…

image1.png
image2.png
image3.png

OR

image-1.png
image-2.png
image-3.png

OR

1.png
2.png
3.png

You get the idea? Get all the images you want rotated in a group, rename them with numbers starting with 1, increment by 1, and proceed in order to the total number of images in the group

Upload all the images to the proper directory

Let’s say, for example, you uploaded the images to a folder named “random”. You are using the image-n.png format where n equals the number of the image. Here’s the path that we’ll use for this example…

<img src="http://www.yoursite.com/folder/random/image-n.png" />

Now here is the php code that is going to replace n with a random number from 1 to the total number of images there is, in this case, 3

<?php echo rand(1,n); ?>

The whole code comes together like this…

<img src="http://www.yoursite.com/folder/random/image-<?php echo rand(1,n); ?>.png" />

That’s about the simplest way to get random rotating images

Leaving a comment with code in it...

If you would like to leave a comment and you have examples of code you want to show, you must "escape the code". This allows the entire code to show correctly by inserting certain variable around certain tags to make them show. If you don't "escape the code" your code will show up broken, mangled, and it won't be able to be seen correctly. "Escaping the code" is very simple...

  1. Copy your code you want to show
  2. Click here to go to the site to escape the code
  3. Follow the directions, it's so easy
  4. Once you have the escaped code copied, paste it in the comments area where you want
  5. Now you can enjoy life


Go ahead, leave a comment...

Leave a Comment

Previous post: Make your own multimedia box

Next post: Multimedia box, feature box, it’s all the same