SinglePageGallery

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


Goal

I have a page filled with thumbnail links to larger images. When I click on a thumbnail, the image usually opens in my window, and I lose the wiki skin in my browser. To retain the skin, I have to create a page for each image, with the larger image displayed inline. This means ceating a LARGE number of pages.

I would like to have a single page for the larger image (call it LargeImage), and have all thumbnail links point to the LargeImage page. Then, when I click on a thumbnail, the LargeImage page would get displayed, with the appropriate image displayed inline.

Solution

First, define the gallery: intermap link (in local/localmap.txt) with:

 gallery    http://www.example.com/pmwiki.php/Group/LargeImage?img=$1

Next, add the following to your local/config.php:

 $DoubleBrackets['{$Img}'] = $_REQUEST['img'];

Finally, in the LargeImage page, put the following markup where you want the passed-in image to be displayed.

 http://www.example.com/path/to/images/{$Img}

In any wiki page you can put the markup:

 [[gallery:photo.jpg /path/to/thumbnail]]

to create a thumbnail that will open in the LargeImage page.

Discussion

In the above example, gallery:photo.jpg becomes a link to
http://www.example.com/pmwiki.php/Group/LargeImage?img=photo.jpg
i.e., it jumps to the LargeImage page and has the desired image passed in the img= parameter.

Inside of LargeImage, the sequence is replaced by the value of the img= parameter, so the markup
http://www.example.com/path/to/images/{$Img}
becomes
http://www.example.com/path/to/images/photo.jpg

which is then converted to an inline image in the LargeImage page.

Example

There is a working example at the following page:

http://www.shyitalia.com/shy.php/English/Photos

Click on any thumbnail, they all open in the same LargeImage page.

See Also

  • PictureGallery -- Display uploaded pictures and automatically create thumbnails for preview
  • X-Gallery -- include an Image Gallery in your Wiki pages
  • EmbeddedGallery -- How to embed the Menalto Gallery inside of PmWiki

Comments & Bugs

Initially the recipe didn't work (no image displayed inline) until I added the intermap link in /scripts/intermap.txt instead of local/localmap.txt.
If you have to resort to this, don't forget to backup your scripts/intermap.txt for it will be overwritten as soon as you upgrade.

Once in the LargeImage page, if you click on the title link the page gets reloaded without any image displayed inline, which can be annoying. Therefore, I've put a [[notitle]] keyword in the LargeImage page to hide the title link.

Contributors

pmwiki-2.2.138 -- Last modified by {{Ugo}}

from IP: 85.171.160.186 ip should be disabled by default for security reasons