Introduction
Created to produce simple, cropped galleries from folders of uploaded images; Point autoGallery at a folder and it will automatically generate thumbnails and then output a series of processed chunks to display the gallery. Since it uses MODx chunks for display it is easy to integrate with any funky image gallery display utility (thickbox, lightbox etc) using the chunk.
now has special handling for .flv and .mp3 files. You can designate a different chunk to be used for these, so they can play in a player when selected from the gallery. You can create a thumbnail for them by simply including an image names filename.flv.jpg (where filename.flv is the video file).
includes the cleanup and additions by radoslaw[at]artengine.pl
now has some additions to support client-side gallery management. Particularly it allows you to specify a chunk to present admin buttons if the user is a member of a specified group.
now has limited support for IPTC data. The list of supported items is available here. The items appear as placeholders in the item chunk, so you can use things like [+iptc_caption+]
includes support for pagination using the pagesize and page arguments (the latter can be retrieved from the request). Also included is support for running two copies of AutoGallery on the same page. If tnprefix is specified then this will allow thumbnails of different sizes and qualities to be created for each call. If this is left blank AutoGallery will autodetect multiple runs and use the prefixes 'tn_', 'tn1_', 'tn2_' etc. If this is used the you must also include a tnprefixes argument as a comma separated list of all the prefixes used on the page. This prevents the generation of "tn1_tn_filename.jpg" on the second pass. It also sets the page placeholders prevpage and nextpage with the number of the previous and next pages respectively to help create forward and back buttons.
Instructions
Installation
Download the two files below. Install the file in - or wherever you prefer. Paste the contents of the file into a snippet called autoGallery (or AutoGallery, or whatever you like). Modify the include line of the snippet if you didn't install the in . Follow the istructions below (repeated in the snippet comment).
For uploading and title/description modification download the files under "". The HTML files are example forms that you can use. Needless to say you will want them behind some form of WebLogin access control, since the management system can add and delete files and doesn't have a whole load of checking in it (so can almost certainly add and delete arbitrary files...).
Useage
will automatically generate thumbnails from a folder full of images. It currently only supports JPG and PNG formats for thumbnail generation and since it uses 'tn_' as the prefix for thumbnails it won't display any of your images that have names starting with this!
AutoGallery takes the following optional arguments:
- These set the width and height in pixels. They default to 190 and 245 respectively
- The name of the chunk for each thumbnail produced. Defaults to autoGalleryItem
- The base path of the galleries. Defaults to assets/galleries. The gallery displayed is $basepath/$gallery, so you should have a folder called assets/galleries/114 for if you are using Document ID as the gallery (the default) and this is page 114
- AutoGallery now supports gallery names based on something more complex than Document ID (although it will default to DocID if you can't be bothered). If no gallery argument is passed it will look for a request variable called 'gallery' and use that value, so you can create a single gallery page and make calls like "gallerypage?gallery=MyPics". If the request variable is also blank it will then default to the document identifier. This must be the name of a folder within basepath, but otherwise can be anything that your filesystem supports. It copes with spaces in folder names on Linux, its untested on other OSes.
- This will be prefixed to the URL of any .mp3 files. This allows you to specify a player. See the default example in the code below for ideas.
- This will be prefixed to the URL of any .flv files. This allows you to specify a player. See the default example in the code below for ideas.
- If this is set then AutoGallery will process this chunk instead of itemchunk when it encounters an mp3 file. It will ignore the mp3player arg, since thats probably in your chunk anyway.
- If this is set then AutoGallery will process this chunk instead of itemchunk when it encounters an flv file. It will ignore the flvplayer arg, since thats probably in your chunk anyway.
- The quality argument to be used for creating PNG thumbnails. For JPEG files this should be between 1 (Unviewable) and 100 (Huge files). For PNG files it should be between 1 and 9 (although it will auto-scale a percentage to fit this range - if you have a mixture of formats, for example)
- If these are set then AutoGallery will process the adminbuttons chunk and place the results in the adminbuttons placeholder if the current user is in one of the groups listed in adminbuttons (comma separated).
- The prefix to be used for the thumbnail files. If this is left blank AutoGallery will autodetect multiple runs and use the prefixes 'tn_', 'tn1_', 'tn2_' etc.
- A comma separated list of prefixes used on this page. If tnprefix is set then this must be included.
- The number of items to display per page. This must be set to turn on pagination.
- Which "page" of results to display. The first page is numbered 1 (sorry, programmers, but this is easier than answering "why does it start at zero?" 9000 times!).
The following placeholders can be used in the item chunk:
- The path of the thumbnail image. (Ideal for use in <img src="[+tnpath+]" />)
- The path to the underlying image. (Perhaps <a href="[+imgpath+]"> around that <img>?). It is still called [+imgpath+] for mp3s and flvs but actually contains the URL for the file, or to call the player if flvplayer and mp3player are used.
- The filename without extension. (Maybe a title? Or some alt-text?)
- The title and description from the modx_gallery_info table of the database. This table is created when you first run AutoGallery. Fill in the gallery and entity columns with the gallery folder and filename (including extension) if you want extra details in the chunk. Feel free to ignore it if you don't want it, it is only accessed once on each AutoGallery invocation.
- The same db data but processed through PHP's rawurlencode for use in URLs.
- The same data as imgpath and tnpath but processed with rawurlencode() for use in URLs.
- If the user is logged in and a member of the specified admin groups, this placeholder will contain the contents of the adminbuttons chunk (which can itself make use of any of the placeholders here). This can present item-specific options like Modify and Delete.
Examples
- This will call AutoGallery with the chunk `galItemChunk` being used for each image. In this case the page usually received a `gallery=blah` argument in the request, which would specify the folder to open. Otherwise it would open the folder corresponding to the page ID (so, /assets/galleries/123 in this case)
- This call specifies a (low) quality be used for the thumbnails. It also specifies that AGChunk be used for all images, but AGMp3Chunk be used for mp3 files (in this case AGMp3Chunk contains a call to a flash mp3 player)
Download
Gallery display
Download both files and follow the instructions above.
Gallery management
Download and paste in these snippets:
These are some example forms and chunks:
These assume the existance of a page with the alias "AutoGalMod", which is nothing more than a call to the AutoGalMod snippet, and a snippet called "setter" which is one line: "$modx->setPlaceholder($arg, $_REQUEST[$arg]);". The galleries are displayed by a page with the alias "gallerypage" and the contents:
[!AutoGallery?itemchunk=AutoGalleryItem&tnwidth=170&tnheight=210
&adminbuttons=GalAdminButtons&admingroups=admins&quality=100!]
[!MemberCheck?groups=admins&chunk=GalAddButton!]
Showcase
Amaryllis Gothic Fashion Model - AutoGallery with ShadowBox integration in the chunk, including Titles.
Contact
If you have questions, comments, complaints, or offers of enormous funding for additional MODx snippet work please contact ramsay@zombietuesday.com
Follow the AutoGallery forum thread here
License
This software is released under the GNU GPL version 3