![]() |
New url_helper anchor tag that allows for an image link - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: New url_helper anchor tag that allows for an image link (/showthread.php?tid=48523) Pages:
1
2
|
New url_helper anchor tag that allows for an image link - El Forum - 05-22-2012 [eluser]Aken[/eluser] Should be useful for those people who are still having trouble grasping how to pass an image to the anchor() function. There are some things I would recommend cleaning up / changing, if you're interested in hearing them. Don't want to just list them off because people usually think I'm a jackass when I do that, even though they're suggestions on how to better the code. New url_helper anchor tag that allows for an image link - El Forum - 05-22-2012 [eluser]InsiteFX[/eluser] I ahve not done anything to the code , It is the url helper code I just added the code for the image. New url_helper anchor tag that allows for an image link - El Forum - 05-22-2012 [eluser]Aken[/eluser] That's one of my points. You already have access to the URL helper, why repeat code that's already there? Your function should only need to adjust what ends up being the $title parameter, then pass everything to and return anchor(). Something worth noting to users, also, is that some browsers (*cough* Internet Explorer) don't play well with img tags that do not have width and height attributes. As handy as this function might be to people, I would recommend creating the img tag either by hand or with the HTML helper img() function, with all appropriate attributes added. Then this function or anchor() can be used. New url_helper anchor tag that allows for an image link - El Forum - 05-22-2012 [eluser]skunkbad[/eluser] I think in the past I just used something like this: Code: echo anchor('whatever.php', img('x.gif') ); New url_helper anchor tag that allows for an image link - El Forum - 05-27-2012 [eluser]adityamenon[/eluser] skunkbad, that will probably just give you a link, whose text is the HTML for an image tag. InsiteFX, here's the gist for your post. It allows forking so others can act on their suggestions... New url_helper anchor tag that allows for an image link - El Forum - 01-11-2013 [eluser]Unknown[/eluser] [quote author="adityamenon" date="1338154422"]skunkbad, that will probably just give you a link, whose text is the HTML for an image tag. InsiteFX, here's the gist for your post. It allows forking so others can act on their suggestions...[/quote] Actually, I was searching for a solution just like this. skunks code works perfectly. Code: <?=anchor('publications/bvbride/2012/fall', img('images/bvbride-2012-fall.jpg'), 'title="Brazos Valley Bride - Fall 2012 Digital Edition"');?> ...yields... Code: <a href="http://bryanbroadcasting.com/publications/bvbride/2012/fall" title="Brazos Valley Bride - Fall 2012 Digital Edition"><img src="http://bryanbroadcasting.com/images/bvbride-2012-fall.jpg" alt=""></a> |