PictureGallery

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


Goal

A picture viewer with thumbnails preview and automatically generated thumbnails.

Solution

Add the following markup: [[$Gallery]].

Files

Attach:gallery.zip

Installation (requires PmWiki-0.6.0 or higher)

Put gallery.php in the local/ directory and add the following line to local/config.php:

  include_once("local/gallery.php");

Usage

Edit your page and insert the markup [[$Gallery]]. Now you can upload (attach) your pictures. JPG, GIF and PNG-files will be accepted. The filename must start with the name of the current wikipage followed by a "_", example: picturegallery_test.jpg. The script automatically generate the thumbnails. The thumbnails-filename start with thumb_.

History

  • March 18, 2004 -- Initial release -- version 0.0.1
  • March 24, 2004 -- Add translation of english (you can choose between german and english), fix problem with path to pictures
  • Juni 07, 2004 -- Support of EXIF and IPTC, add URL for original picture
  • July 25, 2004 -- Now you can disable the support of EXIF and IPTC with $gallery_exif and $gallery_iptc.
  • Oct 23, 2004 -- Bugfix reading error of empty EXIF and IPTC fields.

Comments, Bugs

  • The Gallery requires PHP 4.2 or higher.

additional comment

You may get problems when including a page with a gallery in another group - A little addition to the gallery.php should do the trick:

SDV($InlineReplacements['#\\[\\[\\$Gallery\\s*(.*)\\]\\]#e'], 'gallery($1)');

function gallery($param = '') {

global $UploadDir;
global $pagename;
if ($param <> '') $pagename = $param;(:cellnr bgcolor=#efefef:)
...

}


This is a somehow very dirty way to achieve the goal since you can't use . or / in the Parameter.

  • The point gets absorbed by php somewhere in the Inline-Replacement procedure of pmwiki
  • a slash in the param leads to a php-error-warning (division by zero) and isn't recognized by the array explode from Stefan.

I may look deeper into this - but for now the [[$Gallery]]-Tag works the original and the following way:

[[$Gallery GroupName]] which even works, if the page gets included somewhere else.

I found that if you use $DoubleBrackets instead of $InlineReplacements above, including other WikiGallerys works as expected.

how to support per-page attachments

Make the following mods in gallery():

  global $UploadPrefixFmt;
  ...
  $path = FmtPageName("$UploadDir$UploadPrefixFmt",$pagename);
  $url = FmtPageName("$UploadUrlFmt$UploadPrefixFmt",$pagename);

(note: this still works if attachments are per-group)

I also found that exif_read_data() fails when trying to access .gif files. Add a @ at the start of the line to suppress the warning:

  @$exif = exif_read_data($image[$pic-1]);

Author

pmwiki-2.3.38 -- Last modified by {{}}?

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