Using link_to with an image tag & link text

Hi ,
I was trying to use link_to along with image_tag
to setup a link that would open in an external window.
But I was unable to make a link using both text & an image
So my current workaround looks like this inside a partial
where link is http://foo.com & text would be descriptive

<%= link_to(text, link,
:popup =>true) %>

ideally i would like to use the image_tag inside the link_to & make it
cleaner.

Would appreciate help from anyone on this,

Thanks,
Pete

Pete Gajria wrote:

Hi ,
I was trying to use link_to along with image_tag
to setup a link that would open in an external window.
But I was unable to make a link using both text & an image

What does the original code look like? You should be able to do
something like:

link_to( image_tag(…), url )

John Gray wrote:

Pete Gajria wrote:

Hi ,
I was trying to use link_to along with image_tag
to setup a link that would open in an external window.
But I was unable to make a link using both text & an image

What does the original code look like? You should be able to do
something like:

link_to( image_tag(…), url )

I tried the above which gives me an image with an href
what i want is an image next to some text both of which link to the same
url
so something like this below…which didnt work for me
link_to( image_tag(…), url, text )

aka

link_to( image_tag(…), “http://www.cnn.com”, “Read more news” )

Pete Gajria wrote:

John Gray wrote:

Pete Gajria wrote:

Hi ,
I was trying to use link_to along with image_tag
to setup a link that would open in an external window.
But I was unable to make a link using both text & an image

What does the original code look like? You should be able to do
something like:

link_to( image_tag(…), url )

I tried the above which gives me an image with an href
what i want is an image next to some text both of which link to the same
url
so something like this below…which didnt work for me
link_to( image_tag(…), url, text )

aka

link_to( image_tag(…), “http://www.cnn.com”, “Read more news” )

Ah, I see. The only way I know to do that is to use two link_to calls,
one as above and another using a text string instead of image_tag.

Try doing this:

link_to “Read more news #{image_tag(…)}”, url )

Justin

On Jun 9, 2006, at 7:56 PM, John Gray wrote:

link_to( image_tag(…), “http://www.cnn.com”, “Read more news” )

Ah, I see. The only way I know to do that is to use two link_to calls,
one as above and another using a text string instead of image_tag.

Not so, just do this: (note the ‘+’ btwn image_tag and text)

link_to( image_tag(…) + “http://www.cnn.com”, “Read more news” )

-Rob