Photo Gallery
One of the most demanded features in Couch has been the image gallery.
How to use it
1. Create a clonable template
<cms:template title='Gallery' clonable='1' dynamic_folders='1'> </cms:template>
<cms:template title='Gallery' clonable='1' dynamic_folders='1' gallery='1'> </cms:template>
2. Define editable regions
<cms:template title='Gallery' clonable='1' dynamic_folders='1' gallery='1'>
<cms:editable
name="gg_image"
label="Image"
desc="Upload your main image here"
width="500"
show_preview='1'
preview_height='200'
type="image"
/>
<cms:editable
name="gg_thumb"
assoc_field="gg_image"
label="Image Thumbnail"
desc="Thumbnail of image above"
width='115'
height='115'
enforce_max='1'
type="thumbnail"
/>
</cms:template>
The thumbnail region gg_thumb is used by Couch for displaying the image thumbnails in the admin panel as such it is not advised to modify the dimensions of it. You can always create another associated thumbnail region if you wish to use thumbnails of other dimensions.
3. Creating cloned pages

Also notice the 'Default page' that Couch creates for all cloned templates. For a gallery, this default page is really not needed and you should 'unpublish' it. It gets shown to only the super-admin. The site-owner will never see it.

This is the new mass uploader that ships with Couch.

You'll see Couch uploading and processing the images one after another.
Errors that might occur in the process will be reported as they are encountered - one common error is trying to upload an image that is too large. For now only a maximum size of 2MB is supported.
You might receive errors at this point stating something like 'Access not allowed' or 'Failed to open stream' etc. This can happen if your server is running under SAFE MODE restrictions (this mode has been deprecated but you still might run into some paranoid hosts insisting on using it).
To by-pass these restrictions you'll have to lend a helping hand to PHP by creating some folders and setting their permissions manually.
This thread of our forum discusses the procedure in detail http://www.couchcms.com/forum/viewtopic.php?f=4&t=6912&p=8703.

Couch has not only uploaded en-masse all the images to the server but has also automatically created a cloned page each for every successfully uploaded image.

You'll notice that Couch has used the uploaded image's name as the page's title and name fields. If that does not suit you, you can always edit them.
4. Displaying the gallery
<cms:pages masterpage="gallery.php" include_subfolders='0' >
<a href="<cms:show gg_image />">
<img src="<cms:show gg_thumb />" title="<cms:show k_page_title />" />
</a>
</cms:pages>
New variables
- k_file_name
- k_file_ext
- k_file_size
- file_name
- file_ext
- file_size
EXIF data
As this addition is more likely to be useful to only professional photographers, it is turned off by default. To turn this feature on, please set the following directive in 'config.php' to 1
// 25
// Set the following to '1' if you wish to extract EXIF data from images uploaded to Gallery
define( 'K_EXTRACT_EXIF_DATA', 0 );
- exif_aperture
- exif_color
- exif_componentconfig
- exif_jpegquality
- exif_exifcomment
- exif_contrast
- exif_copyright
- exif_customrendered
- exif_datetime
- exif_datetimedigitized
- exif_zoomratio
- exif_distancerange
- exif_height
- exif_width
- exif_exifversion
- exif_exposurebias
- exif_exposuremode
- exif_exposure
- exif_exposuretime
- exif_fnumber
- exif_flashused
- exif_flashpixversion
- exif_focallength
- exif_focusdistance
- exif_gaincontrol
- exif_isoequiv
- exif_make
- exif_meteringmode
- exif_model
- exif_orientation
- exif_jpegquality
- exif_resolution
- exif_resolutionunit
- exif_saturation
- exif_screencapturetype
- exif_sharpness
- exif_software
- exif_whitebalance
- exif_ycbcrpositioning
- exif_xresolution
- exif_yresolution
<cms:pages masterpage="gallery.php" include_subfolders='0' >
<a href="<cms:show gg_image />"><img src="<cms:show gg_thumb />" title="<cms:show k_page_title />" /></a>
<cms:exif>
Dimensions: <cms:show exif_resolution /><br />
Taken on: <cms:show exif_datetime /><br />
Camera make: <cms:show exif_make /><br />
Camera model: <cms:show exif_model /><br />
Shutter speed: <cms:show exif_exposuretime /><br />
Aperture: <cms:show exif_aperture /><br />
Focal length: <cms:show exif_focallength /><br />
</cms:exif>
</cms:pages>
A note of caution here:
The GD library used on the server side (by Couch as well as most other scripts) for image manipulation has the property of discarding away the Exif data for good from the image being manipulated (resized for example).
As such, once the you turn on the setting to capture Exif data from images, Couch will NOT resize the uploaded images at all.
This is to keep the exif data within the image intact.
Please remember that with this setting on, you'll have to upload the images already resized on your local machine using any Exif savvy program (like IrfanView).
If this is not possible for the client, a workaround could be to define a new thumbnail associated with the main image that has the proper dimension. The original image will be left untouched however the thumbnail can now be used instead of the original image itself.
A working sample Gallery
To jump-start your development, here is a complete sample gallery template that can be used as a guide (or even 'as-is' if you are in a hurry - the markup is neutral enough to go with almost any design).


Download the template here.
Download the Slimbox version here (this is another version of the same template using JavaScript (Slimbox) to display the images).
