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) |
How to link image with anchor function - El Forum - 11-18-2008 [eluser]umefarooq[/eluser] Hi i want to put link on an image but anchor() function is working for text what about if i want to put link to an image any helper function for this. How to link image with anchor function - El Forum - 11-18-2008 [eluser]rogierb[/eluser] I use a customs function for images: Code: function anchor_image($url, $image, $attributes = '', $image_attributes = '') { Edit: Code is f*cked: Use: ja-va-script: where is says [removed] Just remove the -. How to link image with anchor function - El Forum - 11-18-2008 [eluser]Yash[/eluser] simple just use anchor_url and in second parameter a pass a string as <img src=" '.base_url().'source/image.jpg' '" /> How to link image with anchor function - El Forum - 11-19-2008 [eluser]umefarooq[/eluser] hi here is my code for the link an image using CI anchor and img functions. Code: function anchor_img($uri = '',$img = '', $title = '', $attributes = '') and here how we will pass arguments in two different ways Code: anchor_img('test.htm',array('src'=>'admin/images/unpublish.png','border'=>'0'),'testing image') second way Code: anchor_img('test.htm','admin/images/unpublish.png','testing image') How to link image with anchor function - El Forum - 11-19-2008 [eluser]umefarooq[/eluser] little more change in function Code: function anchor_img($uri = '',$img = '',$attributes = '') How to link image with anchor function - El Forum - 11-19-2008 [eluser]xwero[/eluser] The problem with the custom functions is that they are limiting the possibilities to generate the a tag as you want. The anchor function doesn't check if the second argument contains no tags so you can do Code: anchor('test',img(array('src'=>'admin/images/unpublish.png','border'=>'0','alt'=>'testing image')),array('class'=>'imglink')); How to link image with anchor function - El Forum - 11-19-2008 [eluser]umefarooq[/eluser] wow really nice an simple one line of code.. thanks for help How to link image with anchor function - El Forum - 06-01-2009 [eluser]ayukawaa[/eluser] The answer of xwero does not work, I have found that the simplest form of doing it without bother with custom functions is using %s as the anchor() title and then replace the %s with the img() using printf I have put it in many lines to better read: Code: printf This way is simply and clear because anchor() and img() are CI internal functions. Note: - you must use the title="something" in the anchor (if not, CI will add title="%s" ) - the img() is in the html helper ^_^ How to link image with anchor function - El Forum - 09-24-2009 [eluser]Eason[/eluser] Here is my version of anchor_img() function: Code: /** To make it works, this function should be placed in system/helpers/url_helper.php or system/application/helpers/MY_url_helper.php How to link image with anchor function - El Forum - 03-09-2010 [eluser]elaniobro[/eluser] [quote author="Eason" date="1253874144"]Here is my version of anchor_img() function: Code: /** To make it works, this function should be placed in system/helpers/url_helper.php or system/application/helpers/MY_url_helper.php[/quote] So I put this code into the system/helpers/url_helper.php on line 220 right after the anchor popup function. I tried using this line of code but nothing is showing up on my site: Code: <?= anchor_img('/resume/download',array('src'=>'img/resume/resume_dl.gif','border'=>'0'),'testing image') ?> |