CodeIgniter Forums
How to link image with anchor function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to link image with anchor function (/showthread.php?tid=13305)

Pages: 1 2 3 4


How to link image with anchor function - El Forum - 02-23-2011

[eluser]Unknown[/eluser]
Code:
&lt;?php $img_edit = '<img src="'.base_url().'images/build/edit.png"/>'?&gt;
&lt;?php echo anchor('persons/edit/'.$query_person[$i]['id'], $img_edit);?&gt;



How to link image with anchor function - El Forum - 04-05-2011

[eluser]keld[/eluser]
I thought I would just add my two cents to this thread about embedding images in anchor tags
Code:
//Link + no title + Image + no alt
&lt;?php echo anchor("products/product/".$featured['nameuri'], img('images/featured/'.$featured['photo_featured'])); ?&gt;
outputs:
Code:
<a href="http://www.mysite.com/products/product/productname"><img src="http://www.mysite.com/images/featured/feat_105x145.png" alt=""/></a>
and
Code:
//Link + title + image + no alt
&lt;?php echo anchor("products/product/".$featured['nameuri'], img('images/featured/'.$featured['photo_featured']), 'title="'.$featured["name"].'"'); ?&gt;
outputs:
Code:
<a href="http://www.mysite.com/products/product/productname" title="My Title"><img src="http://www.mysite.com/images/featured/feat_105x145.png" alt=""/></a>
and
Code:
//Link + title + image + alt
&lt;?php echo anchor("products/product/".$featured['nameuri'], img(array('src'=>'images/featured/'.$featured['photo_featured'], 'alt'=>$featured["name"])), 'title="'.$featured["name"].'"'); ?&gt;
outputs:
Code:
<a href="http://www.mysite.com/products/product/productname" title="My Title"><img src="http://www.mysite.com/images/featured/feat_105x145.png" alt="My Alt"/></a>