[title sub="Written by Chris Graham (ocProducts)"]Composr Tutorial: Providing galleries[/title]

[surround]
[media width="150" description="An image in a gallery" float="right"]data_custom/images/docs/tut_galleries/gallery_view_image.png[/media]
[media width="150" description="Adding an image to a gallery" float="right"]data_custom/images/docs/tut_galleries/gallery_add_image.png[/media]
{!galleries:DOC_GALLERIES} This tutorial describes the basic gallery features, and how to use them.

[contents]decimal,lower-alpha[/contents]
[/surround]

[title="2"]Gallery structure and settings[/title]

[surround]
[media width="150" description="Galleries are structured. Here is a gallery that has a subgallery" float="right"]data_custom/images/docs/tut_galleries/gallery_subcat.png[/media]
A gallery is a category of the gallery system, and is used to hold images and videos (together, gallery entries). Galleries can also hold audio files which are treated in the same way as videos.

Galleries are organised in a hierarchical (tree) structure. For more information of these tree structures, see the [page="_SEARCH:tut_downloads"]Providing downloads tutorial[/page], as the download system is the perfect clean example of a Composr tree-structured system. The gallery structure is more complex than that of the download structure, and additional information on it is given in the [page="_SEARCH:tut_adv_galleries"]Advanced galleries tutorial[/page].

Galleries are given a name, and a title. The name should be a code-name that can easily be typed in a URL, rather than a cleanly readable name. For example, 'holiday2004' would be a good gallery name for a gallery with title, 'Holiday Pictures, 2004 (Sweden)'.

Galleries may have 'representative images' (rep-images). When a user views a gallery with sub-galleries, the sub-galleries are actually shown with their rep-images, so as to make them look more attractive and give an impression of the contents. Rep-images may be chosen when adding or editing a gallery, or when adding an image to a gallery it can be chosen that that image shall also become the rep-image.

You will find icons to add/edit galleries/images/videos at:
Content Management > Galleries

You can delete a gallery/image/video from the bottom of its edit form. The root gallery cannot be deleted, however.
[/surround]

[title="2"]Viewing galleries[/title]

[surround]
[media width="150" description="A gallery in regular-mode mode" float="right"]data_custom/images/docs/tut_galleries/gallery_not_flow_mode.png[/media]
[media width="150" description="A gallery in flow mode" float="right"]data_custom/images/docs/tut_galleries/gallery_flow_mode.png[/media]
There are two display modes for galleries:
1) Flow mode -- this mode allows you to see all the entries in the gallery at the same time as viewing one of the entries. This makes navigation more efficient. Note that there is a limit of 40 media files displayed in the carousel, so flow mode is only a good option for small galleries.
2) Regular-mode -- this mode provides page browsing features so as to be able to browse through a large numbers of entries.

Regardless of display mode, the user can choose any of the available entries (images or videos), and the chosen entry will be presented to the user.

Galleries are viewed from the [tt]galleries[/tt] module ([tt]site:galleries[/tt] page-link, Content > Galleries home on the default menus).

[title="3"]More about gallery display modes[/title]

You can lock-down the gallery display mode choice for new galleries using the "Gallery display mode" config option. Existing galleries will only allow the display mode to be changed if it is not already matching the value of this option (i.e. you keep your pre-existing gallery settings, but if you then change a gallery to be the same as the locked-down value then it will then also lock-down).
If the choice is not locked-down then the default will be whatever is the current most common display mode used on your site.

[title="3"]Block[/title]

There is a block, [tt]main_gallery_embed[/tt], that can be used for embedding images and videos directly into another page. The selection of images and videos is based on configurable criteria.

The default look of this block is plain, but advanced slider interfaces can be created by re-templating this block.
[/surround]

[title="2"]Images[/title]

[title="3"]Image formats[/title]

The following image formats can be used:
 - [tt].jpg[/tt]/[tt].jpeg[/tt] -- highly compressed, but loses image accuracy. Great for photos because the accuracy loss is hard to notice for natural scenes.
 - [tt].png[/tt] -- well compressed, with no accuracy loss. My personal favourite choice if bandwidth is not generally constrained. Soon will be able to do animation too via [url="APNG"]http://caniuse.com/#feat=apng[/url].
 - [tt].gif[/tt] -- useful if you need animation, but limited to 256 colours and poor compression. Generally a poor choice, use video or APNG instead.

[title="2"]Videos[/title]

Galleries have powerful video support. Composr will analyse the file types of uploaded videos and use carefully crafted templates that use browser plug-ins that are most appropriate to that file type. For example, QuickTime files will be displayed with HTML to use the QuickTime plugin.

Composr can usually auto-detect video widths, heights and lengths, from the actual video files.

[title="3"]Video formats[/title]

Composr supports most video formats, but video on the web is fraught with complexity.

The following formats are best to use:
 - [tt].mp4[/tt] (with h.264 aac encoding)
 - [tt].webm[/tt] (the Google-sponsored format, supported natively in all web browsers except Internet Explorer/Microsoft Edge and Safari, but available in those via normal system codec plugins)

The following are almost as good:
 - [tt].mov[/tt] (with h.264 aac encoding -- this modern QuickTime format is identical to mp4)
 - [tt].flv[/tt] (works as long as Flash is installed -- won't work on iOS devices)

The following common formats are not safe:
 - [tt].avi[/tt] (could be many different codecs, no consistent support even for the MPEG-compatible encodings like DivX or XVid or MS-Video, plus your browser might not load the correct plugin)
 - [tt].wmv[/tt]/[tt].asf[/tt] (requires Windows Media Player plugin, only properly supported on Windows)
 - [tt].ogv[/tt] (Ogg video, essentially replaced by WebM)
 - [tt].mpeg[/tt]/[tt].mpg[/tt] (old MPEG formats, no consistent plugin support, plus your browser might not load the correct plugin)
 - [tt].rm[/tt]/[tt].ram[/tt] (requires RealPlayer plugin, not available on Linux)
 - [tt].qt[/tt] (Old quicktime format)

Further documentation is provided in the [page="_SEARCH:tut_fringe"]Supplementary web technologies (media, social networking, etc) tutorial[/page].

At the end of the day it may be best just to use the galleries on your site as a wrapper around YouTube. Read on.

[title="4"]Transcoding[/title]

You can set it up so that any video format is 'transcoded' to MP4 by setting the FFMPEG executable path in the configuration. For this to work, 'FFMPEG' needs to be installed on the server. The default transcoder settings are set to produce MP4 h.264 DVD-quality movie files.

Unfortunately FFMPEG does have some major problems with audio/video synchronisation, mixed bit-rates, and lack of adaption to corrupt files, and incompatibilities between versions. It is also fairly slow to run, so can consume server resources, and could result in timeouts on some configurations.

The best solutions (for those who can't invest heavily in heavy-weight transcoding solutions) are:
1) just use YouTube. You can post videos on YouTube, then add a video in Composr using the normal YouTube URL as the video URL. Composr will then automatically embed the YouTube player.
2) just post in h.264 [tt].mp4[/tt] to start with. It has become the standard and is supported in all browsers. The only down-side is having to learn how to set your codec settings right when you make the video file.

[title="3"]Audio[/title]

Audio is supported as specialisation of video support. i.e. a gallery must have video files enabled for it, for audio files to be supported.

In fact, virtually any kind of media, including random things like URLs to Google Maps, may be posted as a video. The media rendering system Composr uses is quite extensive.

[title="3"]Length, width, and height[/title]

Composr can sometimes automatically detect width/height/length of uploaded videos/audio.

If it can't be auto-detected then you should enter it manually, as it can cause various issues, such as misreported lengths in podcasts.

However, if you install the non-bundled getid3 addon then this can work much more consistently.

[title="2"]Ordering[/title]

Gallery entries are ordered in the same order they were added to the system. If you are batch importing (covered in the [page="_SEARCH:tut_adv_galleries"]Advanced galleries tutorial[/page]), then you may want to define a custom ordering. To do this, you just need to give all the images in the batch names that are consistent with a numbering scheme of your choice. Composr will detect numbering schemes automatically, and order by them.

The rule is very simple: Composr will order by filename if when taking all numbers out of all filenames in the gallery, the filenames are all the same.

For example, a gallery with the following named files would not be ordered according to a scheme:
 - foo.png
 - foo1.png
 - foo2.png
 - foo2something.png
But without the last image, the contents would be ordered by filename.

[title="2"]Slide-shows[/title]

When viewing an image or video visitors will be able to start moving through all the subsequent images/videos in the gallery automatically. This is referred to as a slide-show. Visitors may pause the slide-show via a click or keypress, which could be triggered via a hand-held USB control device (as such devices can be mapped to such input actions).
If you would like to change the speed of the slide-show you can do it via editing the [tt]GALLERY_ENTRY_SCREEN.tpl[/tt] template.

On some browsers, alt-clicking on the slideshow will activate the browser full screen mode.

[title="2"]Watermarking[/title]

When you add or edit a gallery you may choose watermarks to be automatically added to any of the 4 corners of any added images that you select to be watermarked. A watermark is just a semi-transparent image that is overlaid across images as an official mark, or to prevent unauthorised reproduction. If you wish to place a watermark on an edge, you simply make a corner watermark image that includes enough transparency to change the location for the main image to be placed.

Watermarks will appear on your full image where-ever it is displayed. Composr will not save a copy of images without the watermarks applied. They are applied permanently when you add/edit new image files. You will therefore want to ensure you keep your own media archive should you wish to change how you do watermarking later on.

Watermarks are actually 'inherited' in the tree structure: in other words, when adding an image, watermarks will be chosen from the first gallery back down towards the root gallery that actually defines watermarks.

[title="2"]e-cards[/title]

When viewing an image visitors will have an option (if the [tt]recommend[/tt] addon is installed) to send the image as an e-card. This is a good form of website promotion, as the e-card also functions as a kind of website recommendation.
If you don't want this feature you can remove it by editing the [tt]GALLERY_ENTRY_SCREEN.tpl[/tt] template.

[concepts
 1_key="Gallery"     1_value="A category for images and videos"
 2_key="Rep-image"   2_value="An image chosen to represent a category, when a box for it is displayed"
 3_key="Watermark"   3_value="A standard mark shown on an image to mark its identity, often done for a number of different reasons"
 4_key="Flow mode"   4_value="The gallery view mode intended for attractive display of small galleries"
 5_key="Subgallery"  5_value="A gallery placed beneath another gallery"
]Concepts[/concepts]

[title="2"]See also[/title]

 - [page="_SEARCH:tut_featured"]Featuring content[/page]
 - [page="_SEARCH:tut_downloads"]Providing downloads[/page]
 - [page="_SEARCH:tut_adv_galleries"]Advanced galleries[/page]
 - [page="_SEARCH:tut_fringe"]Supplementary web technologies (media, social networking, etc)[/page]

{$SET,tutorial_tags,Galleries,galleries,Content,novice}{$SET,tutorial_add_date,Aug 2008}{$SET,tutorial_summary,A gallery system is provided for the storage, organisation and viewing of images and videos.  Read about it.}[block]main_tutorial_rating[/block]
