Extension:RandomImage

The Random Image extension adds a  tag to the MediaWiki parser which allows for randomisation of multimedia content on a page.

When the tag is rendered, a random image is selected from those uploaded and inserted at the location of the tag. Users can select a custom size, float and provide a caption for the resulting image.

Installation

 * 1) Check out all extension files from Subversion and place them in a RandomImage subdirectory within your MediaWiki extensions directory
 * 2) Add the line   to your LocalSettings.php file

Installation can be verified through the Special:Version page on the wiki.

Inserting a random image
The tag can be used in two forms:

The tag also supports the following attributes:
 * &lt;randomimage /&gt; : Produces an image using an automatic caption (see below)
 * &lt;randomimage&gt;&lt;/randomimage&gt; : Produces an image with a preset caption (text inside the tags)

For example:
 * size : Set the image width (default is the user's thumbnail width)
 * float : Float the image; valid values are 'left', 'center' and 'right'
 * choices : Confines image selection to a pipe-delimited list of images



Caption
If no caption is specified, one will be pulled, if possible, from the image description page.

If the description page contains text wrapped in &lt;randomcaption&gt;&lt;/randomcaption&gt; tags, then this will be used as the caption. The tags are ignored during normal page views. Otherwise, the first paragraph of the page text will be used as the caption.

Selection
On wikis where non-images are uploaded (e.g. sound and video files, or documents, etc.), the extension might select a non-image file. There are few performance-efficient means of limiting those files selected.

If $wgRandomImageStrict is switched on, a more complex database query will be performed, with a greater performance cost, which will ensure only images with an "image" major MIME type are selected.

By default, this option has the same value as $wgMiserMode. You may wish to switch it off if all of the content on your wiki has an appropriate renderer.

Caching
By default, the output is cached in the regular parser cache. This can be advantageous on larger sites which need to use caching to reduce the effects of load, however, it means that content is not 100% dynamic.

To disable the parser cache on pages which use the  tag, set $wgRandomImageNoCache = true;</tt> in LocalSettings.php</tt> (after the call to include the extension file). This will affect all users, and might incur additional overhead on pageviews.