html_image
html_image é uma função customizada que gera uma tag HTML para uma imagem.
A altura e a largura são automaticamente calculadas a partir do arquivo de imagem se
nenhum valor é fornecido.
basedir é o diretório base do qual caminhos relativos de imagens estão baseados.
Se não fornecido, o document root do servidor (variável de ambiente DOCUMENT_ROOT) é usada
como o diretório base. Se a segurança está habilitada, o caminho para a imagem deve estar dentro
de um diretório seguro.
href é o valor href para onde a imagem será linkada. Se um link é fornecido,
uma tag <a href="LINKVALUE"><a> é posta em volta da tag da imagem.
Nota Técnica:
html_image requer um acesso ao disco para ler a imagem e calcular
a altura e a largura. Se você não usa caching de template, normalmente é
melhor evitar html_image e deixar as tags de imagem estáticas para performance
otimizada.
Exemplo 8-7. html_image 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"}
MOSTRA: (possível)
<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" /> |
|