Reputation: 19664
I have read other threads on how to do this and they do not work for me. Can someone tell me how to make an image a anchor in CI?
I have tried these:
<li><?php echo anchor("Home",img("../application/images/Home_up.png")); ?></li>
and
<li><?php echo anchor("Home",img("src"=>"../application/images/Home_up.png")); ?></li>
Upvotes: 1
Views: 6867
Reputation: 359
Have you tried assigning the img function to a variable, and passing that to the anchor function? Something along the lines of:
<?php $img = img('../application/images/Home_up.png'); ?>
<li><?php echo anchor('home', $img); ?></li>
Be sure you have the HTML and URL helpers loaded.
Edit @Dolph and everyone else: This is now TESTED. It WORKS as of 1.7.2.
Perhaps instead of downvoting me, you could have tested it yourself and proved me wrong. Also, I don't see anywhere in his original post anything like the above code. He passed the img function output right into the anchor function - which does not always work. Two functions that spring to mind that wont let you do this are isset and empty. There are many more.
Upvotes: 1
Reputation: 7895
With the url helper loaded either via the contoller ($this->load->helper('url');
) or via the helper array in /system/application/config/autoload.php
; try:
anchor('Home',img(array('src'=>'../application/images/Home_up.png','border'=>'0','alt'=>'Home')));
Upvotes: 3
Reputation: 8035
There is no native way to make an image anchor. There are some functions that override the anchor() function though, search in the CI forums and wiki.
Upvotes: 0