WauloK : The life and interests of an Aussie

I use multi-million dollar satellites to find tupperware in the bush!

Random Img Displayer

Donate!

If you find this useful please consider a donation… Clicking the button donates just (AUD) $1.00!


RndImgDisplayer WordPress plugin by Jason Oakley

I wanted to have random images display on the front page of my website, but could not find a plugin for WordPress which automatically created tags for me: alt, height, width. So, I wrote it myself.

To use: Unzip the zip file into a directory on your PC and upload the whole folder to the wp “plugins” directory. No need to edit anything.

Go into your WP admin plugin page and activate the plugin. You will have to size your images yourself. I keep them all the same size to keep it consistent, but RndImgDisplayer will do the size tags automatically regardless.

Create a subdirectory under the rndimgdisplayer plugin folder called “randomimages”. (Sorry. Winzip and *nix zip will not zip up empty directories).

Drop the files you wish to display into this directory.

Add the following code to your template (I use it in my sidebar).

<?PHP displayrndimg(); ?>

If you have any problems with it, turn on debugging and it will output some helpful data for you:

<?PHP displayrndimg(1); ?>

If you want to turn on alt text displayed under the image:

<?PHP displayrndimg(2); ?>

If you wish to turn on image borders use the optional border variable:

<?PHP displayrndimg(0,1); ?>

You can combine both if you wish:

<?PHP displayrndimg(2,1); ?>

I’ve now added a CSS tag for this plugin. You can use it similar to this in your Stylesheet:

/* RndImgDisplayer */

#rndimgdisplayer { background: #000000; color: #ffffff; font-weight: normal; }

Download: RndImgDisplayer1_2.zip You can see the plugin in operation on the front page of my blog.

This plugin is now on the WordPress plugins site with it’s own page.

Update: v1.1: Fix for img src url bug found by James Gemmill. Update: v1.2: Added optional text below image for Jo & Vinnie. Added optional border around image for Jo. Added CSS elements for formatting.

  • James Gemmill
    Hi,

    This looks great, but my images aren't displaying, though the alt text is. I tried the debugger and everything seems in order. The page in question is here:

    http://test.throneworld.com/lords01/

    Cheers!
  • Ah okay. You don't have WP installed in the root directory, it's in a subdirectory "lords01". I will work on that tonight and release 1.1 if I can fix it. Thanks.
  • James Gemmill
    Works beautifully!

    Thanks!
  • Glad to hear it James :)
  • Lovely, works perfectly and is keeping a client happy..Thank you!
  • Jo
    Hey that's great!

    Couple of questions though - how can I get it to put a border around each image? And also, is there a way of getting to display the title as well as the alt text? I use FF which doesn't display the alt tag :(
  • Jo.
    Sure! I can probably put that together for you soon. Keep checking back. I see I have your email address so I might email you there when this feature is available, too.
    Glad you like it!
  • Great job and thanks, works a real breeze ;-) and yes the option to add alt would be welcome.
  • Jo
    Cheers :)
  • There ya go.. and other updates as well :) Enjoy..
blog comments powered by Disqus