This page last changed on May 23, 2007 by rosie@atlassian.com.
This page describes an unfinished feature of Confluence, for technical users who wish to play with it. The features and modifications described in this page are not officially supported.
The GalleryMacro that is used to draw image galleries in a Confluence page has an undocumented "theme" parameter that allows you to specify a different Velocity template from which to draw the gallery. This allows enterprising Confluence administrators to come up with their own photo-album themes.
You will need:
- A basic knowledge of Velocity markup
- Access to put files in Confluence's installation directory
- Access to restart the server, since getting Java to reload resources it has pulled from the classpath is really hacky.

Instructions:
The Velocity template used to draw image galleries is in WEB-INF/classes/templates/macros/gallery-default.vm, and as it stands it's 22 lines long and very basic.
However, you can change this with the undocumented "theme" parameter in the gallery macro. {gallery:theme=fish} will attempt to draw the gallery with /templates/macros/gallery-fish.vm from anywhere in the application's CLASSPATH. So all you need to do is write the velocity file, dump it in the right directory and restart the server.
If the gallery macro turns out to be something people really use, we'll probably make gallery themes a supported feature with a user interface, a way to drop in theme packs, and so on. For now it's a back-door hack.
Objects Passed to the Template:
$galleryTitle |
is the gallery titled specified for the macro. It may be null. |
$thumbnails |
the container for all the pictures in the gallery (Defined as an inner class in GalleryMacro.java, if you've got the source and want a look) |
$thumbnails.size |
total number of thumbnails in the gallery |
$thumbnails.thumbnails |
a list of all thumbnails in the gallery |
$thumbnails.rows |
a list of lists: each representing one row in the gallery (each list will be of length $thumbnails.columns, see the note below) |
$thumbnails.maxHeight |
the height, in pixels, of the tallest thumbnail in the gallery |
$thumbnails.maxWidth |
the width, in pixels, of the widest thumbnail in the gallery |
$thumbnails.columns |
the number of columns that the gallery should be drawn with |
NOTE: The last row of the thumbnail gallery may contain empty cells. In this case, because Velocity is really broken with regards to its handling of nulls, the final list in $thumbnails.rows may be padded to its full width with the string "BLANK". Be sure to check for this.
The ThumbnailInfo objects themselves that you get out of $thumbnails (Defined in ThumbnailInfo.java if you've got the source and want a look):
$thumbnail.originalWidth |
width in pixels of the full-sized image |
$thumbnail.originalHeight |
height in pixels of the full-sized image |
$thumbnail.thumbnailWidth |
width in pixels of the thumbnail |
$thumbnail.thumbnailHeight |
height in pixels of the thumbnail |
$thumbnail.thumbnailUrlPath |
the path to download the thumbnail image, relative to the application's context path ($req.contextPath) |
$thumbnail.getPopupLink(imageParameters) |
returns the HTML to draw the thumbnail image as a popup link for the full-sized image attachment. imageParameters is a string that can contain HTML attributes for the image tag so for example you could call $thumbnail.getPopupLink("border='1' align='right'"). If you don't want any parameters, just pass in null or the empty string. |
$thumbnail.attachment.downloadPath |
the path to download the full-sized image, relative to the application's context path. |
$thumbnail.attachment.comment |
the image's attachment comment |
|