PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

html_image | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

html_image

Attribute NameTypeRequiredDefaultDescription
filestringYesn/aname/path to image
borderstringNo0size of border around image
heightstringNoactual image heightheight to display image
widthstringNoactual image widthwidth to display image
basedirstringnoweb server doc rootdirectory to base relative paths from
linkstringnon/ahref value to link the image to

html_image is a custom function that generates an HTML tag for an image. The height and width are automatically calculated from the image file if none are supplied.

basedir is the base directory that relative image paths are based from. If not given, the web server document root (env variable DOCUMENT_ROOT) is used as the base. If security is enabled, the path to the image must be within a secure directory.

link is the href value to link the image to. If link is supplied, an <a href="LINKVALUE"><a> tag is put around the image tag.

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-7. html_image

index.php:

require('Smarty.php.class');
$smarty = new Smarty;
$smarty->display('index.tpl');

index.tpl:

{image file="pumpkin.jpg"}
{image file="/path/from/docroot/pumpkin.jpg"}
{image file="../path/relative/to/currdir/pumpkin.jpg"}

OUTPUT: (possible)

<img src="pumpkin.jpg" border="0" width="44" height="68">
<img src="/path/under/docroot/pumpkin.jpg" border="0" width="44" height="68">
<img src="../path/relative/to/currdir/pumpkin.jpg" border="0" width="44" height="68">
忘却曲線を使ってこの関数を確実に記憶に残す

フォーラムで「html_image」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | html_image」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: