From f653a2fe2f82130ff9d8db6a4913b4823dd81424 Mon Sep 17 00:00:00 2001
From: Derek Allard 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 = 'Helpers & Plugins
echo heading('Welcome!', 3);
The above would produce: <h3>Welcome!</h3>
- +Lets you create HTML <img /> tags. The first parameter contains the image source. There is data, the + second the size of the heading. Example:
+img('images/picture.jpg');
+// gives <img src="http://site.com/images/picture.jpg" />
+There is an optional second parameter that is a TRUE/FALSE value that specifics if the src should have the page specified by $config['index_page'] added to the address it creates. Presumably, this would be if you were using a media controller.
+img('images/picture.jpg', TRUE);
+// gives <img src="http://site.com/index.php/images/picture.jpg" />
Additionally, an associative array can be passed to the img() function for complete control over all attributes and values.
+ $image_properties = array(
+ 'src' => 'images/picture.jpg',
+ 'alt' => 'Me, demonstrating how to eat 4 slices of pizza at one time',
+ 'class' => 'post_images',
+ 'width' => '200',
+ 'height' => '200',
+ 'title' => 'That was quite a night',
+ 'rel' => 'lightbox',
+ );
+
+ img($image_properties);
+ // <img src="http://site.com/index.php/images/picture.jpg" alt="Me, demonstrating how to eat 4 slices of pizza at one time" class="post_images" width="200" height="200" title="That was quite a night" rel="lightbox" />
Lets you create HTML <link /> tags. This is useful for stylesheet links, as well as other links. The parameters are href, with optional rel, type, title, media and index_page. index_page is a TRUE/FALSE value that specifics if the href should have the page specified by $config['index_page'] added to the address it creates.
link_tag('css/mystyles.css');
--
cgit v1.2.3-24-g4f1b