Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

Mini

Summary: Simple, lightweight, un-bloated thumbnail and gallery generator
Version: 20080717b
Maintainer: Petko
Categories: Images, Uploads
Discussion: Mini-Talk

Description

Simple, lightweight, un-bloated square thumbnail and gallery generator for PmWiki.

Mini is a new image gallery and thumbnail generator for PmWiki. It was born out of the well known ThumbList.

Mini is used in the place of the PmWiki Attach: markup, but instead of displaying the original picture, a smaller version (thumbnail) is automatically created and displayed, with a link to the original file.

These pictures come from Public Domain collections at Wikimedia
Each thumbnail links to the original picture

The main differences from ThumbList are:

  • Square thumbnails. Mini extracts square thumbnails from the original pictures. Squares combine better and arguably look better.
  • Simpler. Easier to use than Thumblist. The script has very few options, none of which is written in the wiki page. The only wiki markup is Mini:image.jpg.
  • Un-bloated. Mini has only a few features, only the most needed ones for an online wiki gallery. No tables, no template trails, no captions, no multiple thumb sizes, no unsupported filenames.
  • Lightbox. Mini works more easily and simply with Lightbox to produce high quality, special effects slideshows.
  • Smaller and faster. The full script is 5 times smaller than the full Thumblist. It should load faster.
  • Integrated. Mini can be used with standard PmWiki markup dealing with images, including frames, tooltip titles, captions and links.

Mini is also compatible with Thumblist : it is possible to use both recipes at the same time.

Examples

Please link your Mini wiki-galleries below.

  • Mini Homepage (sort of), you can see it in action
  • ...your gallery here...

Installation

  • Download the archive mini.zipΔ.
  • Copy mini.php to your cookbook directory; copy the directory lb (the Lightbox files) to your farm's /pub/ directory.
  • Add to a local config file include_once("$FarmD/cookbook/mini.php");
  • Add to a local CSS file, for example /pub/css/local.css, the line
    .mini { padding:2px; border:1px solid #dddddd; background-color:#ffffff; }

Usage in a wiki page

Single thumbnails and lists:

  • Mini:picture.jpg produces a thumbnail of picture.jpg
  • Mini:pic1.jpg,pic2.jpg,pic3.jpg produces a list of selected thumbnails
  • Mini:* lists all thumbnails in the upload directory
  • Mini:r*,S*,t* lists pictures starting with R, S or T (case insensitive)
  • Mini:*.jpg,-pic1.jpg lists all JPGs except pic1.jpg
  • Mini:pic1.jpg,* first pic1.jpg, then all others (pic1 will not be repeated)
  • Mini:*,pic1.jpg same as the previous one; fully defined pictures are displayed before wildcard lists

Galleries of files, attached to a different wiki page:

  • Mini:Group/Page/picture.jpg one picture
  • Mini:Group/Page/* all pictures

Note that thumbnails from other groups or pages are created with the other groups/pages settings.

Tooltip titles and captions (both optional):

  • Mini:picture.jpg"A tooltip title" | A caption below the result is the same you would have with http://site/thumbnail.jpg"A tooltip title" | A caption below, see PmWiki.Images.

Thumbnails without links to the originals:

  • mini:picture.jpg or mini:* - lowercase "mini:" produces no links

Alternative links to pages/urls instead of to the originals:

  • [[Other page | mini:picture.jpg ]] - note the lowercase "mini:"
  • [[Other page | mini:picture.jpg"Tooltip title" ]] | Caption with [[link]] - you can have tooltips and captions too

List thumbnails in 4 columns, like in a table :

>>width=450px<<
Mini:*
>><<

The default thumbnails are 100 px wide, with some padding/margins between them, that's why we set width>400px for the div block.

Files not found

If you list in Mini:file.jpg a file that is not found in the uploads directory, the markup is transformed into a regular Attach:file.jpg link which allows you to upload a file with that filename. Note that Mini uses the same function as Attach: to search for the file; if the filename is not allowed by PmWiki, Mini: as well as Attach: links will fail to display it (and instead will offer a link to upload it with a standard filename).

Removing the thumbnails

To remove all generated thumbnails, use a link [[Your page?action=purgethumbs]]. They will be recreated on the next page view. You may need to purge the thumbnails if you change some configuration variable, like Px, Quality or CropYPos, explained below.

Configuration

The following variables can be set in config.php before including the mini.php script. They can also be placed in local configuration files.

Thumbnails

  • $Mini['Px'] = 160; change the thumbnail dimensions (default is 100 pixels)
  • $Mini['Quality'] = 95; change the JPEG quality of the thumbnails; default is 90; 100 is best, but the file size gets bigger
  • $Mini['BgColor'] = array(0xff, 0xff, 0xff); the background color of the thumbnails, in Red-Green-Blue notation (similar to #ffffff for white). The background will be visible if a picture has transparency, or if it is smaller than the thumbnail size, in that case it will be centered in the thumbnail canvas. Demo.

Positioning the thumbnail

Thumbnails are square while original pictures may be rectangle. In this case, the thumbnail will be extracted from a square area in the original picture. By default, this square area is centered in the original picture, but you can change this.

  • $Mini['CropYPos'] = 0.2; (must be between 0.0 and 1.0, default is 0.5) vertical position of the cropped area, when the picture is vertical. 0 means the top of the original will be shown in the thumbnail, 1 means the bottom. If you are displaying primarily portraits of people, you may want to set it to 0.
  • $Mini['CropXPos'] = 0.5; position of the crop window for horizontal pictures (0:left, 0.5:center, 1:right).

Lightbox

Lightbox [1] is an unobtrusive JavaScript used to overlay images on the current page and display them in nice slideshows. And in browsers with JavaScript turned off it simply defaults to linking to the original picture. Here are the configuration settings:

  • $Mini['EnableLightbox'] = 1; to enable Lightbox slideshow mode 1 (default is disabled, can be 1, 2 or 3). There are three modes of Lightbox slideshows:
    • 1 : all thumbnails in the page form an "image set"; with < and > arrows you can see them all
    • 2 : each Mini: set is in an independent "image set"; < and > arrows show only the pictures in the current Mini: markup
    • 3 : each thumbnail is independent; the original is displayed with Lightbox but no < and > arrows, and sliding to prev/next is disabled.
  • $Mini['LbUrl'] = '/pub/lb'; to change the location of the lb directory containing Lightbox; default is "$FarmPubDirUrl/lb"
  • $Mini['LbMaxH'] = 800; $Mini['LbMaxW'] = 800; the maximum height and width of the original pictures to be inserted in a Lightbox slideshow. If a picture is bigger, Lightbox is disabled for it, and it is displayed directly in the browser. These options exist because if a visitor has a smaller screen than the picture, playing it in Lightbox may not be nice. Default value for both options is "0", and all pictures are displayed in Lightbox.

Notes

Unlike ThumbList, Mini does not work with non-standard filenames, unrecognized by the PmWiki core (like: filenames with spaces or uppercase extensions). Mini is only expected to work if the same file can be displayed both with an Attach: link, and in the (:attachlist:) directive. The best way to have "standard" filenames is to upload your files by the PmWiki's ?action=upload function.

The thumbnails are stored in the same directory as the original pictures. They are created only once (or if the original pictures are modified). If you change some configuration variable like $Mini['Px'], you need to purge the thumbnails in order to let Mini recreate them with the new parameters. Purging the thumbnails is done with [[Page?action=purgethumbs]].

Thumbnails will all have the same dimensions (default: 100x100 pixels). You can have different sizes on different groups or pages via standard per group customization. To have different size thumbnails on the same page, you can upload them in a different wiki page and change the configuration settings for that page.

Like ThumbList, Mini can work with $EnableDirectDownload set to 0, and with any $UploadPrefixFmt settings.

The easiest way to create wiki galleries is to enable uploads "per-page" instead of the PmWiki's default "per-group". See UploadsAdmin and $UploadPrefixFmt.

Change Log / Release Notes

  • 20080717b : fixed a bug introduced earlier today with LbMaxH and LbMaxW (reported by Damien); $FarmPubDirUrl is left to be expanded on output (suggested by Pm).
  • 20080717 : fixed $FarmPubDirUrl if unset; changed default LbMaxH and LbMaxW to 0 (disabled).
  • 20080713b : thumbnails are now subtly sharpened, if your PHP supports imageconvolution; added Lightbox modes
  • 20080713 : initial public release

See Also

  • ThumbList, another gallery script with more features, and much more configuration options and parameters.

Authors

Mini is written and maintained by Petko. The script is partially based on ThumbList (also by Petko) and on PmWiki's uploads.php script by Pm.

Lightbox [2] and its underlying libraries are written by a number of people. See source files for authors and free software licenses. Lightbox was slightly modified by Petko to work with PmWiki directories and the recipes ThumbList and Mini.

Comments

Your comments are welcome at Mini-Talk.

Edit - History - Print - Recent Changes - Search
Page last modified on July 19, 2008, at 12:06 AM