39 require_once $smarty->_get_plugin_filepath(
'shared',
'escape_special_chars');
49 $server_vars = ($smarty->request_use_auto_globals) ?
$_SERVER :
$GLOBALS[
'HTTP_SERVER_VARS'];
50 $basedir = isset($server_vars[
'DOCUMENT_ROOT']) ? $server_vars[
'DOCUMENT_ROOT'] :
'';
51 foreach($params as $_key => $_val) {
63 if(!is_array($_val)) {
66 $smarty->trigger_error(
"html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
72 $prefix =
'<a href="' . $_val .
'">';
77 if(!is_array($_val)) {
80 $smarty->trigger_error(
"html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
87 $smarty->trigger_error(
"html_image: missing 'file' parameter", E_USER_NOTICE);
91 if (substr(
$file,0,1) ==
'/') {
92 $_image_path = $basedir .
$file;
97 if(!isset($params[
'width']) || !isset($params[
'height'])) {
98 if(!$_image_data = @getimagesize($_image_path)) {
99 if(!file_exists($_image_path)) {
100 $smarty->trigger_error(
"html_image: unable to find '$_image_path'", E_USER_NOTICE);
102 }
else if(!is_readable($_image_path)) {
103 $smarty->trigger_error(
"html_image: unable to read '$_image_path'", E_USER_NOTICE);
106 $smarty->trigger_error(
"html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
110 if ($smarty->security &&
111 ($_params = array(
'resource_type' =>
'file',
'resource_name' => $_image_path)) &&
112 (require_once(SMARTY_CORE_DIR .
'core.is_secure.php')) &&
114 $smarty->trigger_error(
"html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE);
117 if(!isset($params[
'width'])) {
118 $width = $_image_data[0];
120 if(!isset($params[
'height'])) {
121 $height = $_image_data[1];
126 if(isset($params[
'dpi'])) {
127 if(strstr($server_vars[
'HTTP_USER_AGENT'],
'Mac')) {
132 $_resize = $dpi_default/$params[
'dpi'];
133 $width = round($width * $_resize);
134 $height = round($height * $_resize);
137 return $prefix .
'<img src="'.$path_prefix.$file.
'" alt="'.$alt.
'" width="'.$width.
'" height="'.$height.
'"'.$extra.
' />' . $suffix;