Source for file function.html_image.php
Documentation is available at function.html_image.php
* Smarty {html_image} function plugin
* Purpose: format HTML tags for the image<br>
* - file = file (and path) of image (required)
* - height = image height (optional, default actual height)
* - width = image width (optional, default actual width)
* - basedir = base directory for absolute paths, default
* is environment variable DOCUMENT_ROOT
* - path_prefix = prefix for path output (optional, default empty)
* Examples: {html_image file="/images/masthead.gif"}
* Output: <img src="/images/masthead.gif" width=400 height=23>
* @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image}
* @author Monte Ohrt <monte at ohrt dot com>
* @author credits to Duda <duda@big.hu> - wrote first image function
* in repository, helped with lots of functionality
* @uses smarty_function_escape_special_chars()
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
$server_vars =
($smarty->request_use_auto_globals) ?
$_SERVER :
$GLOBALS['HTTP_SERVER_VARS'];
$basedir = isset
($server_vars['DOCUMENT_ROOT']) ?
$server_vars['DOCUMENT_ROOT'] :
'';
foreach($params as $_key =>
$_val) {
$smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
$prefix =
'<a href="' .
$_val .
'">';
$smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
$smarty->trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
if (substr($file,0,1) ==
'/') {
$_image_path =
$basedir .
$file;
if(!isset
($params['width']) ||
!isset
($params['height'])) {
$smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
$smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
$smarty->trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
($_params =
array('resource_type' =>
'file', 'resource_name' =>
$_image_path)) &&
$smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE);
if(!isset
($params['width'])) {
$width =
$_image_data[0];
if(!isset
($params['height'])) {
$height =
$_image_data[1];
if(isset
($params['dpi'])) {
if(strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
$_resize =
$dpi_default/
$params['dpi'];
$width =
round($width *
$_resize);
$height =
round($height *
$_resize);
return $prefix .
'<img src="'.
$path_prefix.
$file.
'" alt="'.
$alt.
'" width="'.
$width.
'" height="'.
$height.
'"'.
$extra.
' />' .
$suffix;
/* vim: set expandtab: */
Documentation generated on Sun, 09 Mar 2008 23:51:59 -0300 by phpDocumentor 1.4.0