From HoverCloud

Photo gallery image (click to enlarge)

Photo Extension

MediaWiki Tag for use with Gallery

I have written an extension for mediaWiki, which you may feel free to copy and distribute (as long as you don't charge anything for it and leave the credits within it intact). It makes it possible to define <photo> tags in your wiki pages that grab pictures from your Gallery. You either specify an album directory from Gallery (to get a random image from the album), or select a single picture from an album for display, see Using the Photo Tag Within Wiki Text below. The pictures are thumbnail size (like the one on the right) and click through to their larger-sized version within your Gallery.

By default, all images are floated to the right. They are placed inside a div tag with the class name "rightphoto". All images are given the class name "borderedphoto". You could define the style for these in your css file if you like, however, the default behavior is that the styling will be added to your page just before the first use of the tags, and it'll be the value of $imgArrayDivStyling within the extension file (which is something reasonable). I've set it up this way so that they will work right off, regardless of your wiki skin.

Installation

To install the extension:

  • find your mediaWiki installation and copy these two files, imgarray.php (http:/downloads/imgarray.php.txt) and PhotoExt.php (http:/downloads/PhotoExt.php.txt) into your mediaWiki's extensions directory
  • make sure you rename the two files so that they end in .php (and not .txt like they are here so they can be viewed and downloaded)
  • edit the PhotoExt.php file to set the name of the directory where your Gallery is located on your web site (e.g. mine is at pics) and any other settings at the top of the file as you wish
  • activate the extension, include it from your LocalSettings.php file by placing this at the end of it: include("extensions/PhotoExt.php");
  • place <photo></photo> in one of your wiki pages to try it out (assuming you already have some images in your Gallery)


Using the Photo Tag Within Wiki Text

What it looks like What you type

Photo gallery image (click to enlarge)

The image rotation system uses thumbnails from the photo gallery. Within the <photo></photo> tags you may specify the directory name of one album (as seen in the URL, not within the title of the pages).

By default a picture is floated to the right, with the top of the picture beginning where the tag was placed in the text, so it is generally a good idea to include the tag before the paragraph next to which you'd like it to appear.


Photo gallery image (click to enlarge)

If you don't place an album directory within the tag, you will get a random picture picked from amoung all of the albums in the gallery.

If you include this tag more than once on the page, you will get a different picture every time, even if you use the same album directory in them all. Pictures will not be selected from sub-albums.


Photo gallery image (click to enlarge)

If you place the word left within the tags, separated from the album name with a comma, the picture will be floated to the left instead of the right. Note also that if you place a directory name (from the gallery) and an image name from within that directory together, instead of a random image you will get the one specific image you have asked for.

<photo>snow</photo>
The image rotation system uses thumbnails from
the photo gallery. Within the <photo></photo>
tags you may specify the directory name of one
album (as seen in the URL, not within the title
of the pages).

By default a picture is floated to the right,
with the top of the picture beginning where the
tag was placed in the text, so it is generally
a good idea to include the tag ''before'' the
paragraph next to which you'd like it to appear.

<photo></photo>
If you don't place an album directory within the
tag, you will get a random picture picked from
amoung '''all''' of the albums in the gallery.

If you include this tag more than once on the
page, you will get a different picture every
time, even if you use the same album directory
in them all.  Pictures will not be selected from
sub-albums.

<photo>left,snow/06_backyard</photo>
If you place the word '''left''' within the tags,
separated from the album name with a comma,
the picture will be floated to the left
instead of the right.  Note also that if you place
a directory name (from the gallery) and an image
name from within that directory together, instead
of a random image you will get the one specific
image you have asked for.