Developer center » Album skins » Variables

Variables

Template file variables

The web pages Jalbum generates are based on "template pages" which can contain html and css code mixed with special elements, scripts and variables that are expanded to their values. When referring to a variable in html context, use the format ${variable}. In scripting context or when used in existence testing (see ja:if exists element) simply use variable name as is. The following variables are defined. Note that case IS significant:

Note: There is an older syntax for referring to variables in html context which looks like this: $variable. Please avoid using this syntax as it isn't sensitive to scopes or variables that change due to scripts.

General
Meaning
cols
Number of image columns on index pages
currentRows
Number of image rows on current index page
generator
Name and version of Jalbum
generatorUrl
Address to the Jalbum homepage (v4.3)
imageNum
Number of the current image within a slide
indexImageCount
Number of images on current index page
indexNum
The number of the current index page 1
internalVersion
Internal version number (since v4.1)
level
Level of album directory (0 meaning root level)
maxImageWidth
Max image width as set by user
maxImageHeight
Max image height as set by user
maxThumbWidth
Max thumbnail width as set by user
maxThumbHeight
Max thumbnail height as set by user
rows
Max number of image rows on index pages
skin
Name of current skin
style
Name of current style sheet
description
Description for album directory (v6)
totalIndexes
Total number of index pages 1
totalAlbumImages
Total number of images in an album (subdirectory images included)
totalImages
Total number of images in a directory
textEncoding
Character set and encoding of generated pages and comments
language
Define as user defined variable to explicitly set a language for a multilingual skin (ISO two character language code)
executedNormally
Set to true after successful (not aborted or error) album generation. Can be referred to in finally.bsh
Navigation
Meaning
folder
Only defined if curent file is a folder/directory. Use in ja:if exists tests (v6)
firstIndexPage
Filename of the first index page
lastIndexPage
Filename of the last index page
previousIndexPage
Filename of the previous index page 2
nextIndexPage
Filename of the next index page 2
parentIndexPage
Filename of parent index page 2
closeupPath
Path to get from index page to closeup image (or slide)
iconPath
Path to icon for directories not having a thumbnail image and other non-image files
thumbPath
Path to thumbnail image
rootPath
Path to get back to the top of a multi directory level album
imagePath
Path to the image that is shown in slides
originalPath
Path to original file. Only defined if linking is "Link to originals via scaled images" or if an original is included for a specific image. If linking is "Link to originals" then imagePath links to the original image
mediarssPath
Path to the Media RSS version of this album (if any)
stylePath
Path to the selected style file
styleFile
Filename of the selected style file. Deprecated. Please use stylePath instead
resPath
Path to the "res" directory containing album resources (support files like gif buttons etc)
firstPage
Filename of the first slide page
lastPage
Filename of the last slide page
previousPage
Filename of the previous slide page 2
currentPage
Filename of the current slide page
nextPage
Filename of the next slide page 2
indexPage
Filename of index page for current slide
File metadata
Meaning
label
Base name (without extension) of file or folder
fileName
Full name of image/movie or folder
title
Alternative name for this file or folder, or if not set, same as label
folderTitle
Alternative name for this folder/album
fileTitle
Alternative name for this file (v8.0)
rating
Rating. If rated, a number between 0 and 5 (v8.0)
thumbWidth
Width of thumbnail image in pixels
thumbHeight
Height of thumbnail image in pixels
imageWidth
Width of image in pixels
imageHeight
Height of image in pixels
originalWidth
Width of original image in pixels
originalHeight
Height of original image in pixels
originalWidthDpi
Horizontal resolution of the original image
originalHeightDpi
Vertical resolution of the original image
formatName
Type of image
compressionLevel
Level of compression as set by the camera
fileSize
Size of original file
fileDate
Date of original file
originalDate
Date written by camera 3
currentDate
Date of album generation
resolution
Original image resolution as written by camera 3
flash
If flash was used 3
focalLength
Focal length 3
exposureTime
Exposure time 3
isoEquivalent
ISO equivalent 3
aperture
Aperture 3
focusDistance
Focus distance 3
meteringMode
Metering mode 3
cameraMake
Camera make 3
cameraModel
Camera model 3
sensorType
Camera sensor type 3
comment
Comment. Will either be extracted from (as soon as found):
  1. An external "texts.properties" file.
  2. The JPEG comment section of an image file.
  3. The IPTC caption section of an image file. 3 (v4.3)
  4. The EXIF user comment secion. 3
keywords
IPTC keywords 3 (v4.3)
category
IPTC category 3 (v4.3)
author
IPTC author 3 (v4.3)
copyright
IPTC copyright 3 (v4.3)

Footnotes:

1 Not defined if only one index page exist

2 Only defined if such page exist

3 Only exists for images containing EXIF/IPTC data and if EXIF extraction is turned on

You can list these variables and their current values by writing <pre><%=current%></pre> into a slide.htt template file.

Implicit objects

Apart from having access to ordinary variables when scripting, Jalbum also provide some special objects (Java type within parenthesis):

Object name
Explanation
out
Page writer. Printing to out will generate output on the resulting page (PrintWriter)
application
Container for variables bound to the current instance of Jalbum (Map)
album
Container for variables bound to the current album generation (Map)
current
Container for all variables bound to the current image (Map)
previous
Container for all variables bound to the previous image (Map)
next
Container for all variables bound to the next image (Map)
local
Container for all variables bound to the local scope. Use to avoid inheritance (Map)
meta
Container for all metadata variables (EXIF etc) found inside an image (Map)
programDirectory
File object representing the current Jalbum directory (File)
skinDirectory
File object representing the current skin directory (File)
skinResDirectory
File object representing the res directory of the current skin (File)
imageDirectory
File object representing the current image directory (File)
rootImageDirectory
File object representing the root image directory (File)
outputDirectory
File object representing the current output directory (File)
rootOutputDirectory
File object representing the root output directory (File)
resDirectory
File object representing the output resource directory (File)
files
Array of File objects for the images and mediafiles in the current image directory (File[])
currentFile
File object representing the currently processed file. A more convenient shorthand for files[imageNum-1] (File)
fileVariables
Container of containers for variables bound to each image. Use File objects from files as key. current for example is a shorthand for fileVariables.get(files[imageNum-1]) (Map)
engine
The album generating JavaBean inside Jalbum. See API (AlbumBean)
window
The window of Jalbum, useful when creating modal popup windows like color pickers etc (Frame)

Note: "current", "previous" and "next" are accessible for slide pages or within a ja:coliterator or ja:fileiterator on index pages

The "meta" object usually contains more EXIF metadata than accessible from ordinary variables, but possibly in a more raw format. You may list all metadata found inside an image by putting the following code inside a slide.htt file:

<pre>${meta}</pre>

The following example picks the "Owner Name" variable out of the meta object (assuming it exists, which it does for some Canon cameras):

${meta.Owner Name}

Understanding variables

Template file variables can be used anywhere where you can put text and html tags (HTML mode) and within <% scriptlets %> (BeanShell mode). In HTML mode, you have to add a dollar sign ($) in front to indicate that this is a variable, in BeanShell mode this is optional but there is another difference: It is important to understand that $variables gets expanded to their value before script execution begins (compare this expansion to a search and replace operation in a text editor). This means that a script cannot change the value of a $variable, but it can change the value of its "shadow" variable (same name but without the dollar sign). The "shadow" variable can later on be referenced from HTML mode like this: <%= variable %>

User defined variables

Jalbum users can define new variables using the "User defined variables" table in the advanced section. These variables behave like other skin template variables and can also override existing variables. You can use user defined variables to add even more flexibility to the look of the skins you create. Usually, user defined variables become variables of String type nomatter what value they have (for backward compatibility). This isn't very convenient if you wish to work a lot with boolean or integer variables (requires type conversion). Automatic type conversion to boolean, integer and double is however performed if Jalbum senses that the particular skin has a custom user interface (see below).

The type conversion is performed like this:

Adding multilingual text

Jalbum has a mechanism to simplifiy writing skins that support texts in several languages (usually navigation strings like "Next" and "Previous" etc). Look at this example:

$text.previousPage

Given the example above, Jalbum will look for a mapping for the "previousPage" "key" in the current language of the user running Jalbum. Jalbum will look into certain property files (see top of page). The format of such a file is simply a list of key=value mappings, one for each row. Please see the "standard" skin for a full working example. Here is a sample Swedish property file (texts_sv.properties):

up=Upp en nivå
previousPage=Föregående sida
nextPage=Nästa sida
firstPage=Första sidan
lastPage=Sista sidan
atFirstPage=Det här är första sidan
atLastPage=Det här är sista sidan
indexPage=Till index sidan
originalImage=Originalbild
cameraInfo=Kamerainformation
        

To support a new language, say German, simply copy and paste such a file, rename it to texts_de.properties and translate the text strings inside. Note: You can force the use of a certain language by setting the "language" user defined variable to an ISO two character code that the current skin has support for.