Lightbox JS is a simple, unobtrusive script used to overlay images on the current page and display them in nice slideshows. This page demonstrates one of all possible ways to integrate this fine JavaScript into PmWiki using Thumblist².

Note that this is different from how it was done in the old version of Thumblist.

See also Mini, a possibly easier way to use Lightbox with PmWiki.

Click on a thumbnail then move your mouse cursor above the image...

(:thumblist px=48 count=8 rel=lightbox:)
2014-11-29T14.01.20-PB297709-Sin.jpeg: 444x351, 13k (2015-03-16 23:22) A_smoky_day_at_the_Sugar_Bowl--Hupa.jpg: 472x640, 50k (2009-02-13 12:30) Achelousaurus_dinosaur.png: 640x640, 575k (2009-02-13 12:30) Aerogelbrick.jpg: 606x640, 62k (2009-02-13 12:30) Atlantis_Docked_to_Mir.jpg: 728x640, 72k (2009-02-13 12:30) Bees_Collecting_Pollen_2004-08-14.jpg: 800x600, 112k (2009-02-13 12:30) BlechnumColensoi.jpeg: 1033x775, 162k (2016-05-16 12:25) Breslau_Ring_Ostseite_1890-1900.jpg: 800x603, 158k (2009-02-13 12:30)

These photos come from Public Domain collections at Wikimedia Commons.[1]

The following picture is 800px wide, it was downsized to 500px

(:thumb Bees_Collecting_Pollen_2004-08-14.jpg width=500 rel=lightbox:)
Bees_Collecting_Pollen_2004-08-14.jpg: 800x600, 112k (2009-02-13 12:30)

The following picture is 341px wide, it was not resized

(:thumb Mcron.jpg width=500 rel=lightbox:)
Mcron.jpg: 1033x775, 162k (2016-05-16 12:27)

Upload the files

These instructions are for Lightbox version 2.10

  • Download, ready for upload.
  • Create a directory inside your /pub directory, like /pub/lb/.
  • Copy there all files from the archive (just the files, no directory, like here).

Inside a local configuration file

Place this code in your config.php (this code was changed 2023-01-19):

$ThumbList['fPreChecks'] = 'uThumbLightbox';
function uThumbLightbox(&$opt) {
  global $HTMLHeaderFmt, $ThumbList;
  $linkrel = IsEnabled($opt['rel'], $ThumbList['LinkRel']);
  if(preg_match("/lightbox/i", $linkrel))
    $LightboxDirUrl = '$FarmPubDirUrl/lb'; # LIGHTBOX DIRECTORY
    $opt['rel'] = 'lightbox[?G]';
    $HTMLHeaderFmt['lightbox'] =<<<EOF
<link rel="stylesheet" href="$LightboxDirUrl/lightbox.min.css" type="text/css" media="screen"/>
<link rel="stylesheet" href="$LightboxDirUrl/mini-lightbox.css" type="text/css" media="screen"/>
<script type="text/javascript" src="$LightboxDirUrl/lightbox-plus-jquery.min.js"></script>
<script type="text/javascript" src="$LightboxDirUrl/mini-lightbox.js"></script>

In case your /pub/lb directory is elsewhere, please change the line $LightboxDirUrl = "/pub/lb"; to point to it. If, for example all your installation is in /pmwiki/ and your /pub/lb directory is inside, you'll have $LightboxDirUrl = "/pmwiki/pub/lb"; (Thanks Simon for catching this.)

Note that this is different from how it was done in the old version. First: the former $ThumbList['LinkAdd'] definition is not needed, it is ignored and can be safely removed. Second: the Lightbox scripts are only loaded if they are needed by the page (rel=lightbox), so this can be enabled for all the website without problems.

In the wiki page

In the wiki page, use the parameter rel=lightbox to enable Lightbox slideshows.

To enable Lightbox for all thumblist galleries by default, set in config.php:

 $ThumbList['LinkRel'] = 'lightbox';

then you need not to write rel=lightbox in the wiki pages.