mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-04 16:20:55 +02:00
164 lines
4.8 KiB
XML
164 lines
4.8 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<sect1 id="language.function.html.image">
|
|
<title>{html_image}</title>
|
|
<para>
|
|
<varname>{html_image}</varname> is a
|
|
<link linkend="language.custom.functions">custom function</link>
|
|
that generates an HTML <literal><img></literal> tag.
|
|
The <parameter>height</parameter> and <parameter>width</parameter>
|
|
are automatically calculated from the image file if they are not supplied.
|
|
</para>
|
|
|
|
<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>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><quote></quote></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>
|
|
<row>
|
|
<entry>path_prefix</entry>
|
|
<entry>string</entry>
|
|
<entry>no</entry>
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
<entry>Prefix for output path</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
|
|
<itemizedlist>
|
|
<listitem><para>
|
|
<parameter>basedir</parameter> is the base directory that relative image
|
|
paths are based from. If not given, the web server's document root
|
|
<varname>$_ENV['DOCUMENT_ROOT']</varname> is used as the base.
|
|
If <link linkend="variable.security"><parameter>$security</parameter></link>
|
|
is enabled, the path to the image must be within a
|
|
<link linkend="variable.secure.dir">secure directory</link>.
|
|
</para></listitem>
|
|
|
|
<listitem><para>
|
|
<parameter>href</parameter> is the href value to link the image to.
|
|
If link is supplied, an <literal><a href="LINKVALUE"><a></literal>
|
|
tag is placed around the image tag.
|
|
</para> </listitem>
|
|
|
|
<listitem><para>
|
|
<parameter>path_prefix</parameter> is an optional prefix string you can give
|
|
the output path.
|
|
This is useful if you want to supply a different server name for the image.
|
|
</para></listitem>
|
|
|
|
<listitem><para>
|
|
All parameters that are not in the list above are printed as
|
|
name/value-pairs inside the created <literal><img></literal> tag.
|
|
</para></listitem>
|
|
</itemizedlist>
|
|
|
|
<note>
|
|
<title>Technical Note</title>
|
|
<para>
|
|
<varname>{html_image}</varname> requires a hit to the disk to read the
|
|
image and calculate the height and width. If you don't use template
|
|
<link linkend="caching">caching</link>,
|
|
it is generally better to avoid <varname>{html_image}</varname> and leave
|
|
image tags static for optimal performance.
|
|
</para>
|
|
</note>
|
|
|
|
<example>
|
|
<title>{html_image} example</title>
|
|
<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>
|
|
Example output of the above template would be:
|
|
</para>
|
|
<screen>
|
|
<![CDATA[
|
|
<img src="pumpkin.jpg" alt="" width="44" height="68" />
|
|
<img src="/path/from/docroot/pumpkin.jpg" alt="" width="44" height="68" />
|
|
<img src="../path/relative/to/currdir/pumpkin.jpg" alt="" 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
|
|
-->
|