Html image
html_image {html_image} is a custom function that generates an HTML tag. The height and width are automatically calculated from the image file if they are not supplied.
Attributes
| Attribute Name | Required | Description |
|---|---|---|
| file | Yes | name/path to image |
| height | No | Height to display image (defaults to actual image height) |
| width | No | Width to display image (defaults to actual image width) |
| basedir | no | Directory to base relative paths from (defaults to web server doc root) |
| alt | no | Alternative description of the image |
| href | no | href value to link the image to |
| href_target | no | href_target value for link opening behaviour as _blank or _self |
| path_prefix | no | Prefix for output path |
basediris the base directory that relative image paths are based from. If not given, the web server's document root$_ENV['DOCUMENT_ROOT']is used as the base. If security is enabled, then the image must be located in the$secure_dirpath of the security policy. See the Security section for details.hrefis the href value to link the image to. If link is supplied, an<a href="LINKVALUE"><a>tag is placed around the image tag.path_prefixis an optional prefix string you can give the output path. This is useful if you want to supply a different server name for the image.- All parameters that are not in the list above are printed as
name/value-pairs inside the created
<img>tag.
{html_image} requires a hit to the disk to read the image and calculate the height and width. If you don't use template caching, it is generally better to avoid {html_image} and leave image tags static for optimal performance.Where the template is:
{html_image file='tplix-logo.jpg'}
{html_image file='/path/from/docroot/tplix-logo.jpg' width=300 height=200}
{html_image file='../path/relative/to/currdir/tplix-logo.jpg'}
The above template will output:
<img src="tplix-logo.jpg" alt="" width="44" height="68" />
<img src="/path/from/docroot/tplix-logo.jpg" alt="" width="300" height="200" />
<img src="../path/relative/to/currdir/tplix-logo.jpg" alt="" width="44" height="68" />