Link_to_image - Remove Border

Hi All,

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:

<%= link_to_image "b_edit", :action => 'edit', :id => part_prefix %>

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?

Thanks in advance

On 1/12/06, Richard B. [email protected] wrote:

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)

That’s not a Ruby on Rails issue, but a CSS styling problem.

Use:

img {
border: 0;
}

in your CSS stylesheet.

Am 12.01.2006 um 13:35 schrieb Richard B.:

Hi, Richard,

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:

http://api.rubyonrails.com/classes/ActionView/Helpers/UrlHelper.html#M000334

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.

Best regards
Jan P.

On 12.1.2006, at 14.35, Richard B. wrote:

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

Jarkko L. wrote:

On 12.1.2006, at 14.35, Richard B. wrote:

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!

Regards

Richard

Hi, Richard,

yes you are combining link_to and image_tag. Therefore you’ll get the
possibilities of link_to which include linking to actions:
http://api.rubyonrails.com/classes/ActionView/Helpers/UrlHelper.html#M000332

Regards
Jan