OxyScripts.com
Menu spacer Home Tutorials Articles Code Forums irc.freenode.net #oxyscripts
Main (PHP)
Home Forums PHP News PHP Tutorials Articles PHP Code Snippets Contact Us Sysadmin Resources Books Template Shop
3rd Party Streams
SlashDot PHPDeveloper.org PHP.Net
Resources
PHP Manual MySQL Manual Smarty Manual PEAR Manual PHP-GTK Manual Symfony Manual
Code Snippets
Authentication Database Graphics HTTP Miscellaneous Time/Date
Affiliates
Scripts TutorialMan TutorialGuide CodingForums.com PHP Scripts Cheap Web Hosting Affordable Web Hosting Dreamweaver Templates

Search This Site :     PHP Function Reference :
 
html_image

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">
 
   Print this page

Top Sponsor
Symantec\'s Norton SystemWorks 2006
Sponsors
CA
Sponsors
AdWords Dominator 125*125
Advertisting

Affiliates
VertexTemplates PHPFreaks CodeWalkers StarGeek DevScripts CGI & PHP Scripts PHP CMS

Shopping Rebates   Sell It 4 You   Flash Page Counters   Get Insured
GPS Tracking Service   Charity Donate Info   Web Site Hosting   VOIP Service

Privacy Policy | Links | Site Map | Advertising

All content on OxyScripts.com is (©)2002-2007

 
Powered by Adrastea - Version 1.0.0. Copyright © Rune Solutions, 2004-2005