mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-04 16:20:55 +02:00
156 lines
5.5 KiB
XML
156 lines
5.5 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<sect1 id="language.function.html.image">
|
|
<title>html_image</title>
|
|
<informaltable frame="all">
|
|
<tgroup cols="5">
|
|
<colspec colname="param" align="center" />
|
|
<colspec colname="type" align="center" />
|
|
<colspec colname="required" align="center" />
|
|
<colspec colname="default" align="center" />
|
|
<colspec colname="desc" />
|
|
<thead>
|
|
<row>
|
|
<entry>Attribute Name</entry>
|
|
<entry>Type</entry>
|
|
<entry>Required</entry>
|
|
<entry>Default</entry>
|
|
<entry>Description</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>file</entry>
|
|
<entry>string</entry>
|
|
<entry>Yes</entry>
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
<entry>name/path to image</entry>
|
|
</row>
|
|
<row>
|
|
<entry>border</entry>
|
|
<entry>string</entry>
|
|
<entry>No</entry>
|
|
<entry><emphasis>0</emphasis></entry>
|
|
<entry>size of border around image</entry>
|
|
</row>
|
|
<row>
|
|
<entry>height</entry>
|
|
<entry>string</entry>
|
|
<entry>No</entry>
|
|
<entry><emphasis>actual image height</emphasis></entry>
|
|
<entry>height to display image</entry>
|
|
</row>
|
|
<row>
|
|
<entry>width</entry>
|
|
<entry>string</entry>
|
|
<entry>No</entry>
|
|
<entry><emphasis>actual image width</emphasis></entry>
|
|
<entry>width to display image</entry>
|
|
</row>
|
|
<row>
|
|
<entry>basedir</entry>
|
|
<entry>string</entry>
|
|
<entry>no</entry>
|
|
<entry><emphasis>web server doc root</emphasis></entry>
|
|
<entry>directory to base relative paths from</entry>
|
|
</row>
|
|
<row>
|
|
<entry>alt</entry>
|
|
<entry>string</entry>
|
|
<entry>no</entry>
|
|
<entry><emphasis>""</emphasis></entry>
|
|
<entry>alternative description of the image</entry>
|
|
</row>
|
|
<row>
|
|
<entry>href</entry>
|
|
<entry>string</entry>
|
|
<entry>no</entry>
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
<entry>href value to link the image to</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
<para>
|
|
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.
|
|
</para>
|
|
<para>
|
|
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.
|
|
</para>
|
|
<para>
|
|
<parameter>href</parameter> 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.
|
|
</para>
|
|
<para>
|
|
All parameters that are not in the list above are printed as
|
|
name/value-pairs inside the created <img>-tag.
|
|
</para>
|
|
<note>
|
|
<title>Technical Note</title>
|
|
<para>
|
|
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.
|
|
</para>
|
|
</note>
|
|
<example>
|
|
<title>html_image example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
require('Smarty.class.php');
|
|
$smarty = new Smarty;
|
|
$smarty->display('index.tpl');
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
where index.tpl is:
|
|
</para>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{html_image file="pumpkin.jpg"}
|
|
{html_image file="/path/from/docroot/pumpkin.jpg"}
|
|
{html_image file="../path/relative/to/currdir/pumpkin.jpg"}
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
a possible output would be:
|
|
</para>
|
|
<screen>
|
|
<![CDATA[
|
|
<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" />
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</sect1>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
--> |