Categories
General

Up2rand 0.1

Up2rand is sort of a proof-of-concept, but probably actually useful too. It provides a template function that displays random images from those you’ve uploaded using the built-in uploader in WP2 (NOT Photopress). I haven’t tested it extensively, but it seems to work. Obviously, it only works with WP2.

Download Up2rand 0.1: up2rand.zip OR up2rand.tar.gz

Installation and use:

Put up2rand.php in your plugins folder and activate it. Insert up2rand() where you want random images in your template (usually somewhere in your sidebar.php). Without any options you’ll get one thumb, linked to the full image in a popup. To get something else, pass some options:

up2_rand($number_of_images, $before_each, $after_each, $link, $popup, $class);

$number_of_images – number of random images to get (reduced if you don’t have enough)
$before_each – what you’d like to put before each thumbnail (such as <li>)
$after_each – what you’d like to put after each thumbnail (such as </li> or <br />)
$link – whether to link the thumbnail or not (TRUE or FALSE)
$popup – whether to link to a popup or not (TRUE or FALSE)
$class – class to use for the image (you can insert a class in your theme’s style file and use it here)

Here’s an example that gets 2 random images, wrapped with <p></p> tags, linked normally (no popup), and using the ‘randimage’ class.

up2_rand(2,'<p>','</p>',TRUE,FALSE,'randimage');