{html_image}

{html_image}用于生成HTML的<img>标签的 自定义函数。 如果没有提供heightwidth参数, 此函数会自动从图片文件计算出来。

参数名称 类型 必选参数 默认值 说明
file string Yes n/a 图片名称/路径
height string No 真实图片高度 图片显示高度
width string No 真实图片宽度 图片显示宽度
basedir string no 网站根目录 相对路径的起始目录
alt string no 图片的说明内容
href string no n/a 图片上的链接地址
path_prefix string no n/a 显示路径的前缀

技术说明

{html_image}需要每次都读取硬盘上的图片,并且计算图片长宽。 除非你开启了缓存,否则一般建议是避免使用 {html_image},用回HTML的IMG标签,会有更高的性能。

Example 8.8. {html_image} 例子


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

  

输出:


<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" />