Welcome Guest, Not a member yet? Register   Sign In
CI 1.6's new image tag helper and linking
#1

[eluser]gabe[/eluser]
How can I make images link through using the available helpers?

Previously I couldn't use the anchor() helper to help me link images. I had to manually write a links using site_url() and then write an image tag using base_url().

Is it now possible to use these two helpers to link images?

Best regards

Gabe
I am so pleased that CI now has an image helper for generating image tags in my html.
#2

[eluser]Isern Palaus[/eluser]
You need to pass something on the third "position" (sorry my English...). Like:

Code:
<?php
     anchor("welcome","<img src=\"".base_url()."img/test.png\" width=\"16px\" height=\"16px\" />","alt=\"This will work, i think\");
?&gt;

With simple quotes is more easy to understand:
Code:
&lt;?php
     anchor('welcome','<img src="'.base_url().'img/test.png width="16px" height="16px" />','alt="This will work, i think"');
?&gt;

Regards,
-- Isern Palaus
#3

[eluser]gabe[/eluser]
Thanks for the reply. Does that mean with the new 1.6 I could do soemthing like this:
Code:
&lt;?= anchor( 'controller/view', img( 'images/button.gif' ) ) ?&gt;

Perhaps the best way is for me to actually try it Smile
#4

[eluser]Isern Palaus[/eluser]
Oh! Yes! I have not seen img() on the HTML helper! Nice to know.

Yes, &lt;?=anchor('welcome',img('image/button.gif));?&gt; is totally working. Remember the ; at the final of the string gabe.

Regards,
-- Isern Palaus
#5

[eluser]gabe[/eluser]
That's great news! This is like Rails now Big Grin Big Grin

As for the ";" I never add it, should I? My code seems to work fine without it.

Thank you for your help Smile
#6

[eluser]Isern Palaus[/eluser]
Mmmmm :-\ I don't know but I think that it's necessary. Probably not ;-).

No problem, you helped yourself. You said anchor and img() ;-)!

See you,
-- Isern Palaus




Theme © iAndrew 2016 - Forum software by © MyBB