Site Map Home This Page: gallery.php

Gallery Plugin

picture browser and slideshow

Mara includes a plugin which allows any directory containing images in jpg, png or gif format to be turned into a full-featured gallery, without the need for any manual inventorying of images or form box-ticking. New images added to the gallery location by FTP or by using the Mara uploader automatically become part of the gallery browser page. As such this represents a significant saving in webmaster donkey-work over systems which require each newly uploaded image to be registered in a database to make them visible to the gallery.

A slideshow function allows for automatic timed display of gallery images, and includes an intelligent zoom capability which displays large images to the best possible advantage within the available screen space, whilst maintaining their correct aspect ratio. Images can be of moderately larger pixel dimensions than the viewing screen without this causing problems, thus a single size of uploaded image file will suit most client computers.

Example:


1;image 2;image 3;image 4;image 5;image 6;image


A small sample of images of varying sizes and aspect ratios.

In line with Mara policy there are no annoying gimmicks like expanding popups, dissolves or fades. Instead the image change is as near to instantaneous as it can be made, which we think creates a more satisfying, more professional look and feel than animated changes. Preloading avoids any 'venetian blind' loading effect, even on slow Internet connections. 

The gallery is subdirectory-aware, and presents a whole directory tree to the viewer such that it appears to be a single list of images. This has significant advantages where several photo-shoots containing same-named images need to be included in one gallery. If there is the risk of a file naming clash or over-write, just upload to separate directories and the clash is avoided.

Galleries would normally be created under the img/ base directory of the website, but this need not be the case.

To use the plugin, include the following php in your page sourcecode:

<?php
include_once(plugin('gallery'));
gallery_browser("img/gallery",10,"80px","250px");
?>

Where "img/gallery" is the location of the pictures in relation to the root of the Mara website. Note that it is a relative path with no leading slash. 10 is the slideshow interval. "80px" is the maximum height of the browser thumbnails, and "250px" the maximum width. That is genuinely all there is to it. Apart from styling the gallery to suit your website, of course.

The gallery display is freeform and floating, and attempts to fit the most suitable number of images into the available screen space. It is not necessary for images to be of identical size or aspect ratio. In general it is best to set the thumb height to be the limiting factor and allow for some latitude on width, as this achieves more even rows in situations where images are a mix of  landscape and portrait.

Thumbnails are created in a 'thumb' directory under each picture directory. If images are replaced with newer files,  then the thumbs are automatically recreated. Note however that if you want to change the thumbnail size, you need to manually delete the existing thumbs, otherwise they will not be updated until the fullsize images are changed.

On first use after an upload, there will be a delay whilst thumbnails are created. The browser may seem unresponsive during this time. For very large galleries, several page refreshes may be needed to create all of the thumbnails.

As of v2.5 the following improvements apply: