MyBB Community Forums

Full Version: A better way for random image rotation?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

Not intrinsically a problem for only MyBB but rather for all sites, random image rotation is needed to randomly change the images on the header, or background sections of my MyBB site and I'm in the search of an efficient way to do that

I've found a way at A list apart but this method has one drawback: It uses the method of giving <img> the "header.php" as the input and that causes reloading of images everytime a page reloads imposing unnecessary strain on both the server and the clients.

I'm using it in
<img id="background-img" class="bg" src="/images/header.php" alt="" /> at the "header" template of MyBB. You can test the script here and see the same background images reload when you refresh the page several times...

Is there a better way for random image rotation?

Thanks.

UPDATE: I have removed the img src="header.php" functionality and now am working on a more suitable way of randomly rotating images (image path output will come from the main application , not at the <img> layer)
Realistically not a better way. Any rotation is going to cause the same issue. Honestly your implementation is really ugly and I'd think you'd be better off just removing it.
(2010-04-27, 03:58 PM)labrocca Wrote: [ -> ]Realistically not a better way. Any rotation is going to cause the same issue. Honestly your implementation is really ugly and I'd think you'd be better off just removing it.
Well I agree, it's not a suitable way especially for big-sized images such as the ones I use as background images.

But still, I wonder if there's a script which does the job which the header.php does in a different way, i.e. random image selection takes place not in <img src="header.php" /> but in the main application and the output is something like

<img src="sample-pic03.jpg" />
<img src="sample-pic01.jpg" />
<img src="sample-pic07.jpg" />
...

for each reload of the page.