changed "link" to "href" in html_image. "link" is still working but deprecated

html_image always renders an alt-tag now (default alt="")
cleaned up indentiation of function.html_image.php
This commit is contained in:
messju
2003-05-04 11:32:54 +00:00
parent f40c0f0b53
commit 2bc360d3c3
2 changed files with 94 additions and 87 deletions

3
NEWS
View File

@@ -1,3 +1,6 @@
- changed "link" to "href" in html_image. "link" is still working
but deprecated (messju)
- html_image always renders an alt-tag now (default alt="") (messju)
- fixed assign attribute for multiple counters (messju) - fixed assign attribute for multiple counters (messju)
- added simple math operators to variables (Monte) - added simple math operators to variables (Monte)
- reverted patch for case-insensitive tag-names (messju) - reverted patch for case-insensitive tag-names (messju)

View File

@@ -38,6 +38,7 @@ function smarty_function_html_image($params, &$smarty)
{ {
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
$alt = '';
$file = ''; $file = '';
$border = 0; $border = 0;
$height = ''; $height = '';
@@ -56,24 +57,27 @@ function smarty_function_html_image($params, &$smarty)
foreach($params as $_key => $_val) { foreach($params as $_key => $_val) {
switch($_key) { switch($_key) {
case 'file': case 'file':
$file = $_val;
break;
case 'border': case 'border':
$border = $_val;
break;
case 'height': case 'height':
$height = $_val;
break;
case 'width': case 'width':
$width = $_val; case 'dpi':
$$_key = $_val;
break; break;
case 'alt':
if(!is_array($_val)) {
$$_key = smarty_function_escape_special_chars($_val);
} else {
$smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
case 'link': case 'link':
case 'href':
$prefix = '<a href="' . $_val . '">'; $prefix = '<a href="' . $_val . '">';
$suffix = '</a>'; $suffix = '</a>';
break; break;
case 'dpi':
$dpi = $_val;
break;
default: default:
if(!is_array($_val)) { if(!is_array($_val)) {
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
@@ -128,7 +132,7 @@ function smarty_function_html_image($params, &$smarty)
$height = round($height * $_resize); $height = round($height * $_resize);
} }
return $prefix . '<img src="'.$file.'" border="'.$border.'" width="'.$width.'" height="'.$height.'"'.$extra.' />' . $suffix; return $prefix . '<img src="'.$file.'" alt="'.$alt.'" border="'.$border.'" width="'.$width.'" height="'.$height.'"'.$extra.' />' . $suffix;
} }
/* vim: set expandtab: */ /* vim: set expandtab: */