Home

HTML/PHP Random Image Rotation – Redux

by David Pankhurst

I’m pleased as punch – I took my picture rotator php code, added a few more tweaks and twiddles, and submitted it to SitePoint.com? Result? They published it, and now I’m an official SitePoint contributor.

For those that missed the earlier posting, the code was a simple random image rotator script in PHP. What made it unique was:

  • It could be called from an <img> tag, allowing it to be used from regular html (important for jobs where PHP pages weren’t an option).
  • It allowed more than one image per page, without repetition (mostly).

The article adds a bit more to the code (including a PHP-only solution). Besides SitePoint, I’ve also posted it to my site (finally!). The code is free for all, and I hope it benefits you (I ask that you keep the copyright in ït and of course think of me when you’ve got a PHP project coming up…)

2 Responses to “HTML/PHP Random Image Rotation – Redux”

  1. Ryan Matteson Says:

    Is there any way to make the thumb images links to enlarged imaged (ie: lightbox…)?

    Cheers!

  2. David Pankhurst Says:

    If you’re using an HTML page to call the images (such as an ebay listing), there’s no easy way, since you’re not actually passing any information along to the page – the image is generated on the PHP side, and no information about which image (and therefore which link) is passed along. If you’re using PHP of course, then you can just include the links when you generate the page.

Leave a Reply