WordPress Plugin: Random Image Selector

UPDATE: December 9, 2007: The Random Image Plugin has been updated! Please see the new post for updates on features, or to comment.



Have you ever wanted to display a random image from a folder on your site? Maybe for a background or banner for your blog? Now there's a quick and easy way to do it: the Random Image Selector plugin for wordpress!

The initial release, version 1.0.2 is available from the WordPress.org plugins site. The download location is http://wordpress.org/extend/plugins/random-image-selector/

The premise of the plugin is quite simple, create a folder on your website where you want to store your randomly selected files. The plugin will select from all the files in that folder, and choose one at random to display. This is a great way to create a random, rotating header for your blog, or even GASP a primitive ad-rotator.

  1. Extract randomImage.php into your wp-content/plugins folder (or a subfolder)
  2. Activate the plugin in WordPress
  3. On the options screen, select the "Random Image" menu
  4. Fill in the values for your physical and http paths
  5. Add some code to whatever page you want to display the image. This is a great way to customize the header image for your wordpress installation. The plugin will look in the folder and randomly select a header image to display. Sample Code: <?php if (function_exists('generateRandomImgTag')) { generateRandomImgTag(); } ?>

I welcome any comments, feedback or suggestions for future iterations. I've got a few ideas myself. I would like to thank Stefan, one of the early adopters, for his feedback and corrections for the documentation. For another look at the plugin in action visit his site stefanmedia.