summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2008-01-30 21:16:01 +0100
committerDerek Allard <derek.allard@ellislab.com>2008-01-30 21:16:01 +0100
commitf653a2fe2f82130ff9d8db6a4913b4823dd81424 (patch)
tree40e6889a4979b925ab991f22a62e77b831774c71 /system/helpers
parent0684897f89f8363dc431e8ade0535bce521a7af2 (diff)
added img() to HTML helper
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/html_helper.php51
1 files changed, 29 insertions, 22 deletions
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 <img /> 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 = '<img ';
- foreach ($stylesheets as $stylesheet)
+ foreach ($src as $k=>$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 = '<link ';
if (is_array($href))
{