| Half as Smart... Twice as Stubborn...

Add a Simple Custom JS Rotator to Thesis Multimedia Box

The default Thesis theme contains a rotator function in the Multimedia Box.

But perhaps you want to make your own, one that is extremely simple to stab into a given post or page, or that can go wherever you like, and can use different numbers of images to draw from, different dimensions, and different images on a per-post (or page) basis?

The Mules do so like to please.

And unlike the last tutorial, which ended in not a little frustration (plus two among our number foundered in the cornfield — there was a reason for the fence), this one’s so simple a wobbly-legged foal could follow along.

If you can paste code and upload images (and know “where they are” in URI terms), you are pretty well finished.

Paste this below gunk into “Custom Multimedia Box Code” (update: the Thesis MM Box no longer supports JS output… the herd hereby declares the comment here to have primacy, allowing your use of this rotator in any hook — tutorial upgrade!) — the box is below the post editing box — and edit the code to grab your own images at certain dimensions… they either need to be all the same dimensions, or you can remove the width and height parameters — not validating code, surely, but the Mules are stubborn and the W3C is pushy.

Mules win.

As usual, when pasting this into your code, you’ll have to check for forward-facing quotes.  If any of you humans know, without plugins, how to make WordPress obey pre or code tags, we’ll send you a bushel of human food. Or at least we’ll consider saying thank you…

<script language="JavaScript">
var img_rnd = new Array ("", "",
var i = Math.floor(3*Math.random());
document.write('<img src="' + img_rnd[i] + '" width="400" height="300" alt="Mules are Faster than Clydesdales" />');

You can see the 400 x 300 dimensions and the alt tag above, these you can change. Also, this is set-up such that three images are rotated (on page load) and if you wish to add more, follow the pattern, then remember to take “# of my images = math floor” which sounds harder than it is – see the 3*Math.random about halfway down? That “3” is “we have three images” – Thesis theme users are a smart lot, you can handle that, right?

So then. Done. [ Update: except not. Because you need to see this comment… ] If you want a TXT file to avoid the forward-quotes issue, it’s here but thanks to Internet Explorer, it’s a ZIP of a TXT because Explorer 7+ runs the code as JS and not text. Sigh.

Oh, and as per usual, kindly use your own path and images. Ours are not attractive; it’s some human female by our estimate.  We keep the pin-up Mule girls in our private collection. Refresh this page a few times and you should see the page-load rotation function (on this post only, at the top… where again, the MM Box is no longer the focus).

Socialist Media for Humans to Click...

Add Unsubstantiated & Wild Claims from Your Fantasy World...

The herd may very well kick or bite your vile spam...

The South Pasture