html_image函數(shù)
html_image函數(shù)
basedir 是相對圖象路徑的基路徑. 如果沒有給出該屬性,將依據(jù)WEB服務(wù)器的根路徑(環(huán)境變量 DOCUMENT_ROOT)為準. 如果模板的安全設(shè)置打開了,圖象的位置必須位于為安全文件夾下.
href 是圖象鏈接指向的位置. 如果設(shè)置了該屬性,圖象兩側(cè)將被加上超級鏈接標簽,形成一個圖象鏈接.
技術(shù)要點: html_image 需要訪問磁盤以獲取圖象的尺寸. 如果不使用緩沖,為了優(yōu)化性能,一般情況下建議使用靜態(tài)圖象標簽而避免使用 html_iamge.
eg:
index.php:
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->display('index.tpl');
index.tpl:
{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="" border="0" width="44" height="68" />
<img src="/path/from/docroot/pumpkin.jpg" alt="" border="0" width="44" height="68" />
<img src="../path/relative/to/currdir/pumpkin.jpg" alt="" border="0" width="44" height="68" />