Forum: Ruby on Rails how to use the 'alt' attribute with images

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Luca S. (Guest)
on 2006-12-22 23:04
Hi All

I would like to display images including the alt tag

So far this seems to come very close

<%= link_to( image_tag("myimg.png", { :border => 0, :alt => "bla bla"
}), :action => "config" ) %>

I see the image and no border (which is what I want :), but no alt!!

Any suggestions why ?

Thnx a lot
LuCa

ps Maybe important, I'm using firefox!
matt (Guest)
on 2006-12-23 00:25
(Received via mailing list)
According to the RDocs, it looks right to me, so I'll defer that part to
a more experienced user.

But I do want to ask why you are using curly braces between border and
alt ??  Is there a benefit there that I'm unaware of?

Matt
Luca S. (Guest)
on 2006-12-23 00:45
The curly braces is something I found on the internet. When I remove
them I get the same result ( no alt )

LuCa
Rimantas L. (Guest)
on 2006-12-23 02:12
(Received via mailing list)
> So far this seems to come very close
>
> <%= link_to( image_tag("myimg.png", { :border => 0, :alt => "bla bla"
> }), :action => "config" ) %>
>
> I see the image and no border (which is what I want :), but no alt!!

Works perfectly for me.

What do you mean by saying you see no alt? Did you look for it in
generated HTML,
or do you expect it to show up like little yellow popup(tool-tip) when
hovering mouse
cursor over image? In latter case only IE will show alt attribute as
tool-tip and IE is wrong.
If you still want this tool-tip you should use title attribute, not alt.

If tool-tip is not that you want, then check your code and generated
HTML. With the code you've
provided I get:
<a href="/test/config"><img alt="bla bla" border="0"
src="/images/myimg.png" /></a> - just how
it is supposed to work.


Regards,
Rimantas
--
http://rimantas.com/
Luca S. (Guest)
on 2006-12-23 12:45
yep, :title attribute is what I need!!

Thnx a lot
LuCa
This topic is locked and can not be replied to.