{html_image}

{html_image} is a custom function that generates an HTML <img> tag. The height and width are automatically calculated from the image file if they are not supplied.

Attribute NameTypeRequiredDefaultDescription
filestringYesn/aname/path to image
heightstringNoactual image heightHeight to display image
widthstringNoactual image widthWidth to display image
basedirstringnoweb server doc rootDirectory to base relative paths from
altstringno""Alternative description of the image
hrefstringnon/ahref value to link the image to
path_prefixstringnon/aPrefix for output path

Technical Note: {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.

Example 8-11. {html_image} example

{html_image file='pumpkin.jpg'}
{html_image file='/path/from/docroot/pumpkin.jpg'}
{html_image file='../path/relative/to/currdir/pumpkin.jpg'}

Example output of the above template would be:

<img src="pumpkin.jpg" alt="" width="44" height="68" />
<img src="/path/from/docroot/pumpkin.jpg" alt="" width="44" height="68" />
<img src="../path/relative/to/currdir/pumpkin.jpg" alt="" width="44" height="68" />