7. Attributes
Attribute Override Priority
The override sequence for all attributes is (uppermost overrides):
- override parameter
- #images.[image_name].styleTable.[attribute_name]
- user.htmlImage.style.[style_name].[attribute_name]
- programmatic default value generation, if applicable.
(Currently only applies to ALT, HEIGHT, and WIDTH attributes.)
Attribute Override Syntax
Attributes in the override parameter are of the form name=value,
where value is a string optionally surrounded by
- straight or curly double-quotes,
- nothing, or
- double square brackets.
Values within straight or curly double-quotes are treated as string literals.
They may contain whitespace.
No conversion or lookup us done on string contents.
The use of straight or curly double-quotes allows htmlImage to properly
recognize values containing spaces (such as alt text), as well as allowing
the alternate enclosure to be included if necessary (i.e., an item in curly quotes
may contain straight quotes, and vice versa).
Values without quotes or brackets (e.g., "border=0") are treated as string literals.
They may not contain whitespace.
No conversion or lookup us done on string contents.
Values surrounded by double square brackets (e.g., "linkto=[[where to go]]")
are treated as glossary or image lookup key tag.
The tag (with the brackets removed) is looked up first in the glossary;
if a glossary entry is found, it is substituted as the attribute value.
If the tag is not found in the glossary, it is looked up in the image hierarchy.
If the tag is found in the image hierarchy, the image's relative URL is generated and
substituted as the attribute value.
If an expansion tag is not found in either the glossary or the image hierarchy,
and imgAttribsMustExpand (a new preference in user.html.prefs) is true,
htmlImage posts a scriptError. If imgAttribsMustExpand is false, it leaves
the attribute value equal to the expansion tag (including brackets).
Note that html.getPref() returns TRUE if it doesn't find a requested preference
entry in user.html.prefs.
User.html.prefs.imgAttribsMustExpand is set to TRUE at installation,
unless it already exists (i.e., from an earlier installation of htmlImage).
The lookup notation ([[...]]) is particularly useful for the LINKTO attribute.
ALT Text
The ALT attribute will be set automatically if the #autoGenAltText directive has been set
to either "file" or "tag" and no value is provided for the attribute through the image data table entry,
the style definition, or the override parameter. If the attribute has been defined in any of these
three places, even if it is defined as "" (the empty string), the attribute's value will not be set.
For autogeneration of the alt text to work, there must be *no* entry named "alt"
in either the style definition table or the styleTable subtable of the image data entry table.
If such an entry exists, it becomes the default entry, according to the override sequence
described above.
The default definition of the button style (user.htmlImage.style.button), for example,
defines alt="" (the empty string) to suppress autogeneration of alt text.
If alt text is defined at some point in the override sequence, it may be suppressed
by including "alt=\""" in the override parameter.
If alt text autogeneration is suppressed by a value of "" (the empty string) at some
point in the override sequence, it cannot be restored by a parameter later in the
override sequence.
HEIGHT and WIDTH
The HEIGHT and WIDTH attributes are treated together, so that proportional
scaling is properly performed when only one is specified.
The HEIGHT and WIDTH attributes will be set automatically if
no value is provided for the either attribute through the image data table entry,
the style definition, or the override parameter. If either attribute has been defined
in any of these three places, even if it is defined as "" (the empty string),
the attributes' values will not be set automatically.
For autogeneration of the height and width to work, there must be *no* entry
named "height" or "width" anywhere in the override sequence (as described above).
The default definition of the default style (user.htmlImage.style.default), for example,
does not define either height or width attributes, thus allowing them to default to
the actual dimensions of the image.
If height or width is defined at some point in the override sequence,
you cannot force auto-generation of the height and width attributes.
LINKTO
If the LINKTO virtual attribute is defined, and its value is not "" (the empty string),
the rendered image tag will be wrapped in an anchor (<a>) tag to make it a hot link
to the destination specified by the LINKTO attribute.
LINKTO is also used for specifying server-side image maps (see below).
Examples:
htmlImage.ImgRef( "myImage" ) generates the tag
<img src="myImage.gif">
htmlImage.ImgRef( "myImage", "linkto=[[myDest]]" ) generates the tag
<a href="http://mysite/somefile.html"><img src="myImage.gif"></a>
URL
If the URL virtual attribute is defined, htmlImage.ImgRef() will return only the URL of the
specified image, rather than the entire rendered image tag. If the URL attribute is
given a value beginning with "abs" (e.g., "url=absolute"), the returned URL is a fully
qualified http URL (e.g., "http://www.yoursite.com/img/image1.gif"); otherwise,
it is relative to the page currently being rendered (e.g., "../img/image1.gif").
The glue routine htmlImage.Url() adds this attribute for you.
Examples:
htmlImage.ImgRef("image1","url") or
htmlImage.Url("image1") returns the string
../img/image1.gif
htmlImage.ImgRef("image1","url=abs") or
htmlImage.Url("image1","abs") returns the string
http://www.yoursite.com/img/image1.gif