Welcome Guest, Not a member yet? Register   Sign In
src attribute of img tag referencing wrong location
#4

[eluser]toopay[/eluser]
Actually, in my opinion, it will be more 'clean' this way :
Code:
function img($args = array())
    {
        $res = '<img';
        foreach($args as $key => $value)
        {
           if($key == 'src')
           {
               $val = ($value != '') ? site_url($value) : site_url('public/images/no_pic.png');
           }
           else
           {
               $val = ($value != '') ? $value : '';
           }
           $res .= ' '.$key .'="'. $val .'"';
         }
         $res .= ' />';
         return $res;
    }
Now you can call it with something like
Code:
echo img(array('src'=>'public/images/'. $image->image_file_name, 'alt'=>'some caption','width'=>100));


Messages In This Thread
src attribute of img tag referencing wrong location - by El Forum - 04-01-2011, 11:13 AM
src attribute of img tag referencing wrong location - by El Forum - 04-01-2011, 12:43 PM
src attribute of img tag referencing wrong location - by El Forum - 04-01-2011, 12:47 PM
src attribute of img tag referencing wrong location - by El Forum - 04-01-2011, 01:21 PM
src attribute of img tag referencing wrong location - by El Forum - 04-01-2011, 03:13 PM
src attribute of img tag referencing wrong location - by El Forum - 04-01-2011, 07:53 PM
src attribute of img tag referencing wrong location - by El Forum - 04-01-2011, 09:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB