Welcome Guest, Not a member yet? Register   Sign In
Download Helper
#5

[eluser]elaniobro[/eluser]
I found this:
http://ellislab.com/forums/viewthread/97297/

And tried putting this in my syetem helper file:
Code:
/**
* @param    string   identical to the 1st param of anchor()
* @param    mixed    identical to the 3rd param of anchor()
* @param    string   the path to the image; it can be either an external one
*                    starting by "http://", or internal to your application
* @param    mixed    image attributes that have similar structure as the 3rd param of anchor()
* @return   string
*
* Example 1: anchor_img('controller/method', 'title="My title"', 'path/to/the/image.jpg', 'alt="My image"')
* Example 2: anchor_img('http://example.com', array('title' => 'My title'), 'http://example.com/image.jpg', array('alt' => 'My image'))
*/

function anchor_img($uri = '', $anchor_attributes = '', $img_src = '', $img_attributes = '')
{
    if ( ! is_array($uri))
    {
        $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
    }
    else
    {
        $site_url = site_url($uri);
    }

    if ($anchor_attributes != '')
    {
        $anchor_attributes = _parse_attributes($anchor_attributes);
    }
    
    if (strpos($img_src, '://') === FALSE)
    {
        $CI =& get_instance();
        $img_src = $CI->config->slash_item('base_url').$img_src;
    }
    
    if ($img_attributes != '')
    {
        $img_attributes = _parse_attributes($img_attributes);
    }

    return '<a href="'.$site_url.'">'.'<img src="'.$img_src.'" />'.'</a>';
}

Now when I put this:
Code:
&lt;?= anchor_img('/resume/download',array('src'=>'img/resume/resume_dl.gif','border'=>'0'),'testing image') ?&gt;

Nothing is happening. Tongue Any ideas?


Messages In This Thread
Download Helper - by El Forum - 03-09-2010, 03:05 PM
Download Helper - by El Forum - 03-09-2010, 07:04 PM
Download Helper - by El Forum - 03-09-2010, 08:15 PM
Download Helper - by El Forum - 03-09-2010, 08:33 PM
Download Helper - by El Forum - 03-09-2010, 08:47 PM
Download Helper - by El Forum - 03-09-2010, 09:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB