From 45c536ad7c25764b4ee101714840937e4def438d Mon Sep 17 00:00:00 2001 From: mohrt Date: Thu, 27 Feb 2003 14:44:34 +0000 Subject: [PATCH] update functionality --- libs/plugins/function.html_image.php | 40 +++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/libs/plugins/function.html_image.php b/libs/plugins/function.html_image.php index cc16a57e..938e386b 100644 --- a/libs/plugins/function.html_image.php +++ b/libs/plugins/function.html_image.php @@ -8,6 +8,8 @@ * Version: 1.0 * Date: Feb 24, 2003 * Author: Monte Ohrt + * Credits: Duda - wrote first image function + * in repository, helped with lots of functionality * Purpose: format HTML tags for the image * Input: name = name of image (required) * border = border width (optional, default 0) @@ -20,9 +22,10 @@ * Output: * ------------------------------------------------------------- */ -require_once $this->_get_plugin_filepath('shared','escape_special_chars'); function smarty_function_html_image($params, &$smarty) { + require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); + $name = ''; $border = 0; $height = ''; @@ -67,23 +70,30 @@ function smarty_function_html_image($params, &$smarty) $_image_path = $name; } - if(!file_exists($_image_path)) { - $smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_ERROR); - } - - if(!is_readable($_image_path)) { - $smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_ERROR); - } - - if(!$smarty->security && substr($_image_path,0,strlen($basedir)) != $basedir) { - $smarty->trigger_error("html_image: (secure) '$_image_path' not within basedir ($basedir)", E_USER_ERROR); - } + if(!isset($params['width']) || !isset($params['height'])) { + if(!$_image_data = getimagesize($_image_path)) { + if(!file_exists($_image_path)) { + $smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_ERROR); + } else if(!is_readable($_image_path)) { + $smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_ERROR); + } else { + $smarty->trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_ERROR); + } + } + if(!$smarty->security && substr($_image_path,0,strlen($basedir)) != $basedir) { + $smarty->trigger_error("html_image: (secure) '$_image_path' not within basedir ($basedir)", E_USER_ERROR); + } + + if(!isset($params['width'])) { + $width = $_image_data[1]; + } + if(!isset($params['height'])) { + $height = $_image_data[2]; + } - if(!$_image_data = getimagesize($_image_path)) { - $smarty->trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_ERROR); } - return $prefix . "" . $suffix; + return $prefix . '' . $suffix; } /* vim: set expandtab: */