From f653a2fe2f82130ff9d8db6a4913b4823dd81424 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Wed, 30 Jan 2008 20:16:01 +0000 Subject: added img() to HTML helper --- system/helpers/html_helper.php | 51 ++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'system/helpers/html_helper.php') diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index f88bc0723..0c884502f 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -184,41 +184,48 @@ if (! function_exists('br')) /** * Image * - * Generates an image tag + * Generates an element * * @access public - * @param integer + * @param mixed * @return string */ -if (! function_exists('image')) +if (! function_exists('img')) { - function image($src = '', $alt = '', $index_page = FALSE) + function img($src = '', $index_page = FALSE) { - $CI =& get_instance(); - - $css = ''; + if ( ! is_array($src) ) + { + $src = array('src' => $src); + } + + $img = '$v) { - if (strpos($stylesheet, '://') !== FALSE) - { - $href = ' href="'.$stylesheet.'"'; - } - elseif ($index_page === TRUE) + + if ($k == 'src' AND strpos($v, '://') === FALSE) { - $href = ' href="'.$CI->config->site_url($stylesheet).'"'; + $CI =& get_instance(); + + if ($index_page === TRUE) + { + $img .= ' src="'.$CI->config->site_url($v).'" '; + } + else + { + $img .= ' src="'.$CI->config->slash_item('base_url').$v.'" '; + } } else { - $href = ' href="'.$CI->config->slash_item('base_url').$stylesheet.'"'; + $img .= " $k=\"$v\" "; } - - $media = ($media !== '') ? ' media="'.$media.'"' : ''; - - $css .= 'link type="text/css" rel="stylesheet"'.$href.$media.' />'."\n"; } - - return $css; + + $img .= '/>'; + + return $img; } } @@ -244,7 +251,7 @@ if (! function_exists('link_tag')) { $CI =& get_instance(); - $link = 'link '; + $link = '