Procedural File: function.pnimg.php
Source Location: /pnRender/plugins/function.pnimg.phpClasses:
Page Details:
Zikula Application FrameworkTags:
smarty_function_pnimg [line 67]
|
Smarty function to provide easy access to an image
This function provides an easy way to include an image. The function will return the full source path to the image. It will as well provite the width and height attributes if none are set.
Available parameters:
- src: The file name of the image
- modname: The well-known name of a module (default: the current module)
- width, height: If set, they will be passed. If none is set, they are obtained from the image
- alt: If not set, an empty string is being assigned
- altml: If true then alt string is assumed to be a ML constant
- title: If not set, an empty string is being assigned
- titleml: If true then title string is assumed to be a ML constant
- assign: If set, the results are assigned to the corresponding variable instead of printed out
- optional If set then the plugin will not return an error if an image is not found
- default If set then a default image is used should the requested image not be found (Note: full path required)
- set If modname is 'core' then the set parameter is set to define the directory in /images/
- nostoponerror If set and error ocurs (image not found or src is no image), do not trigger_error, but return false and fill pnimg_error instead
- gt if set use gettext translation, disable altml and titleml
- all remaining parameters are passed to the image tag
Example: <!--[pnimg src="heading.gif" width="100" border="1" alt="foobar" ]--> Output: <img src="modules/Example/pnimages/eng/heading.gif" width="100" border="1" alt="foobar" />
Example <!--[pnimg src=xhtml11.png modname=core set=powered]--> <img src="/Theme/images/powered/xhtml11.png" alt="" title="" width="88" height="31" />
If the parameter assign is set, the results are assigned as an array. The components of this array are the same as the attributes of the img tag; additionally an entry 'imgtag' is set to the complete image tag.
Example: <!--[pnimg src="heading.gif" assign="myvar"]--> <!--[$myvar.src]--> <!--[$myvar.width]--> <!--[$myvar.imgtag]-->
Output: modules/Example/pnimages/eng/heading.gif 261 <img src="modules/Example/pnimages/eng/heading.gif" alt="" width="261" height="69" />
Tags:
Parameters
| array | $params | All attributes passed to this function from the template |
| object | &$smarty | Reference to the Smarty object |
