mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-10-31 12:21:36 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			157 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			157 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
| <?xml version="1.0" encoding="iso-8859-1"?>
 | |
| <!-- $Revision$ -->
 | |
| <sect1 id="language.function.html.image">
 | |
|  <title>{html_image}</title>
 | |
|   <para>
 | |
|    {html_image} is a
 | |
|    <link linkend="language.custom.functions">custom function</link>
 | |
|    that generates an HTML tag for an
 | |
|    image. The height and width are automatically calculated from the
 | |
|    image file if none are 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>""</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>
 | |
| 
 | |
|  <para>
 | |
|   basedir is the base directory that relative image paths are based
 | |
|   from. If not given, the web server document root (
 | |
|   <link linkend="language.variables.smarty">env</link>
 | |
|   variable  DOCUMENT_ROOT) is used as the base. If
 | |
|   <link linkend="variable.security">$security</link>
 | |
|   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 placed around the image tag.
 | |
|  </para>
 | |
|  <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>
 | |
|  <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
 | |
|    <link linkend="caching">caching</link>,
 | |
|    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>
 | |
| <![CDATA[
 | |
| where index.tpl is:
 | |
| -------------------
 | |
| {html_image file="pumpkin.jpg"}
 | |
| {html_image file="/path/from/docroot/pumpkin.jpg"}
 | |
| {html_image file="../path/relative/to/currdir/pumpkin.jpg"}
 | |
| ]]>
 | |
|   </programlisting>
 | |
|   <para>
 | |
|     possible output 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
 | |
| -->
 |