I am new to both Ruby and Rails, so please be patient with me. I am
currently working on a view for a controller and I have used the
following excerpt:
The image is being displayed and the link is working. However, the
formatting of image rendered produces and thick (1 or 2px) black box
around the image. Is there a method of controlling this border aroung
the image, I would prefer that it be transparent?
The image is being displayed and the link is working. However, the
formatting of image rendered produces and thick (1 or 2px) black box
around the image. Is there a method of controlling this border aroung
the image, I would prefer that it be transparent?
you can specify it in the img tag itself, or modify it with CSS (border:
0px)
further than the other comments that you might (and probably should out
of elegancy reasons) control this behaviour with CSS. You should have a
look at:
There you’ll find an example of specifying :border => 0 and will realise
that link_to_image which is an alias to link_image_to is deprecated.
Please use the notation that is exampled on the link page.
formatting of image rendered produces and thick (1 or 2px) black box
around the image. Is there a method of controlling this border aroung
the image, I would prefer that it be transparent?
Richard,
First of all, link_to_image is deprecated. According to the api docs:
“This tag is deprecated. Combine the link_to and
AssetTagHelper::image_tag yourself instead, like:
link_to(image_tag(“rss”, :size => “30x45”, :border => 0), “http:// www.example.com”)”
That said, you can get rid of the border by just using css:
a img {
border: 0;
}
If you only want this to apply to certain linked images, give them a
class like this:
link_to(image_tag(“rss”, :size => “30x45”, :border => 0, :class =>
“yourclass”), “http://www.example.com”)
formatting of image rendered produces and thick (1 or 2px) black box
around the image. Is there a method of controlling this border aroung
the image, I would prefer that it be transparent?
Richard,
First of all, link_to_image is deprecated. According to the api docs:
“This tag is deprecated. Combine the link_to and
AssetTagHelper::image_tag yourself instead, like:
link_to(image_tag(“rss”, :size => “30x45”, :border => 0), “http:// www.example.com”)”
That said, you can get rid of the border by just using css:
a img {
border: 0;
}
If you only want this to apply to certain linked images, give them a
class like this:
link_to(image_tag(“rss”, :size => “30x45”, :border => 0, :class =>
“yourclass”), “http://www.example.com”)
…and then
img.yourclass {
border: 0;
}
hth,
//jarkko
Thanks for the quick responce:
I did see that the form that I was using was deprecated. However in the
example provided they are linking to a page, will this still work with
an action and controller? If so do you replace the hard link with the
action and controller id strings?
I still need to review the link that Jan suggested!