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 - 03-10-2010 [eluser]elaniobro[/eluser] Nope, can't figure out how to incoportate the 'onmouseover' and 'onmouseout' into the array correctly. How to link image with anchor function - El Forum - 03-10-2010 [eluser]mohsin917[/eluser] Well its look like we have to make changing in img function How to link image with anchor function - El Forum - 03-10-2010 [eluser]elaniobro[/eluser] I like the way you think. I'll just have to figure out how to put that into the img function in php. Rather new so bare with me this could take awhile! How to link image with anchor function - El Forum - 03-10-2010 [eluser]Eason[/eluser] @elaniobro: Putting img() function as the second parameter of anchor() function, just like what you do, is also an elegant way to create image anchor, IMO. I use my own version of anchor_img() just to avoid loading the html helper. For incoportating the onmouseover and onmouseout attributes, I think it should be ok to put them into the options array of img(), in the same way as other attributes, e.g., img(array('src'=>'...', 'onmouseover'=>'...', 'onmouseout'=>'...')). But I never try this before because I usually use jquery to define javascript events. How to link image with anchor function - El Forum - 03-10-2010 [eluser]elaniobro[/eluser] [quote author="Eason" date="1268272828"]@elaniobro: Putting img() function as the second parameter of anchor() function, just like what you do, is also an elegant way to create image anchor, IMO. I use my own version of anchor_img() just to avoid loading the html helper. For incoportating the onmouseover and onmouseout attributes, I think it should be ok to put them into the options array of img(), in the same way as other attributes, e.g., img(array('src'=>'...', 'onmouseover'=>'...', 'onmouseout'=>'...')). But I never try this before because I usually use jquery to define javascript events.[/quote] Yea, I've tried adding the 'onmouseover'=>'...', 'onmouseout'=>'...' didn't work for me. I should look back into this, I am sure it was a syntax thing, there are a lot of ",' etc.. going on. Code: <a> needs to get put into the array, I'd assume something like this: Code: <?= anchor('/thoughts/more/'.$row->id, yet nada is the above syntax correct? I think so, not getting errors How to link image with anchor function - El Forum - 03-10-2010 [eluser]elaniobro[/eluser] Ok, I think I see the problem. the above code outputs this: Code: <a href="http://www.example.com/5/index.php/thoughts/more/5"><img src="http://www.example.com/5/img/thoughts/readmore_a.jpg" id="readMore" border="0" alt="Read More" /></a> there is a missing (') right after "readMore.src" should be "readMore.src'" how can I modify the PHP code to include the missing(')?? I've tried doing: Code: 'onmouseover'=>'readMore.src='.'''.base_url().'img/thoughts/readmore_b.jpg'.';'.'"' but that does not work. nor does: Code: 'onmouseover'=>'readMore.src='.'"'.base_url().'img/thoughts/readmore_b.jpg'.';'.'"' How to link image with anchor function - El Forum - 03-10-2010 [eluser]mohsin917[/eluser] Sorry elaniobro, I was not here. so it what's next did you get mouseover/out.. now? If you will then let me know. How to link image with anchor function - El Forum - 03-29-2010 [eluser]Quaze[/eluser] So i was just looking for some answers on images enclosed in the anchor function and stumbled upon this thread. Just wanted to make a small comment on the mouseover/mouseout problem if it hastn been fixed yet. If you add a class to the image in the image array, you can specify the hover event in css. And what if you just add the jscript mouseover/out to the image array in stead of to the anchor array? havent tried it but imo worth trying out. ~Quaze (still a php newbie) How to link image with anchor function - El Forum - 12-02-2010 [eluser]mike7418[/eluser] I tried adding an image link using the _parse_attributes to added the image attribute. problem was that it put the image attribute on the anchor tag. So I wrote the following into url_helper.php that works for me: Code: /** Then created _parse_img_attributes Code: /** How to link image with anchor function - El Forum - 12-03-2010 [eluser]umefarooq[/eluser] well no need to create whole new function with already exist code you can use old helper function simply have look Code: if ( ! function_exists('anchor_img')) |