soo_image user guide Page 10 of 16 « »
soo_image
<txp:soo_image />
Display a single image.
Attributes
None required (but see paragraph below). Unless otherwise stated, all attributes default to unset (“0” or empty).
Note that name
will override id
. If neither is declared, soo_image
requires article or image context.
By default, the img
tag produced by soo_image
has height
and width
attributes set to the actual image dimensions, in pixels. You can change this in the plugin’s preferences so that these attributes are not added. In either case you can override the default setting by specifying height
and/or width
in soo_image
:
- If your preference setting is to display
height
andwidth
by default, you can suppress this by declaringheight="0"
orwidth="0"
in thesoo_image
tag. You don’t need to declare both; setting either of them will suppress both. - If your preference setting is to suppress both by default, you can override this by declaring
height="1"
orwidth="1"
in thesoo_image
tag. Again, you don’t need to declare both. - As of version 1.0.b.7, thumbnail attributes are treated the same way (Txp version 4.2.0 or later; note that the Txp 4.2.0 upgrade does not automatically add thumbnail height and width to the database for existing images).
You can also assign arbitrary CSS length values to either attribute. In this case, the value will be passed directly to the img
tag. If you assign height
such a value, but declare nothing for width
, the img
tag will have the specified height
but will not have a width
attribute (and vice versa); this preserves the correct aspect ratio.
Setting any of the link-related attributes (link
, link_class
, link_id
, link_rel
, link_to
, or onclick
) automatically enables both link
and thumbnail
.
Image selection attributes
name
(text)
Txp name (from Content->Images) of image to display.id
(integer)
Txp ID (from Content->Images) of image to display.thumbnail
(boolean)
Set to display the thumbnail instead of the full-size image.
Image tag attributes
height
(mixed)- empty (default): add standard
height
attribute (actual image height in pixels) ifdefault_dimensions
preference is on. 0
: Suppressheight
andwidth
attributes ifdefault_dimensions
preference is on.1
: force standardheight
andwidth
attributes whendefault_dimensions
preference is off.- HTML length value for the
height
attribute (e.g. “50%”).
- empty (default): add standard
width
(mixed)
Likeheight
.escape
(boolean)
True by default. Escape HTML special characters in thealt
andtitle
attributes. Set to “0” to leave unescaped.class
(text)
HTML class name for theimg
tag.html_id
(text)
HTML id for theimg
tag.title
(format string)
HTML title attribute for theimg
tag (anda
tag for linked thumbnails). Any occurrences of “{caption}” will be replaced by the image caption from the Txp database; likewise for “{author}” and “{alt}”. Default is “{caption}”.
Linked thumbnail attributes
Note: setting any of these automatically enables both link
and thumbnail
.
link
(boolean)
Display the thumbnail as a link to the full-size image.link_class
(text)
HTML class name for thea
tag.link_id
(text)
HTML id for thea
tag.link_rel
(relation)
HTMLrel
attribute for thea
tag.onclick
(text)
HTMLonclick
attribute for thea
tag.link_to
(URI)
Root-relative URI to link to; if that URI contains a soo_image gallery that includes this image, the link will be to that point in the gallery (works for multi-page galleries).
Example usage
Display the first image in the current image context
<txp:soo_image />
When used without name
or id
attributes, soo_image
displays the first image in the current image context.
Linked thumbnail with onclick
attribute
<txp:soo_image onclick="doSomething(this)" />
might produce
<a href="/images/28.jpg" onclick="return doSomething(this)" title="Sunrise"> <img alt="" src="/images/28t.jpg" title="Sunrise" /></a>
Using the link_to
attribute
<txp:soo_image link_to="gallery/" />
might produce
<a href="gallery/?soo_img_jp=28" title="Sunrise"> <img alt="" src="/images/28t.jpg" title="Sunrise" /></a>
This page has an example of link_to
in action.