Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3: Why does my image_tag automatically add inline style attributes to the HTML making it invisible?

I'm having this really weird problem where the image tags that I put in the views of my Rails 3.0.12 application automatically get inline style, width, and height attributes even though I haven't assigned them and overriding my CSS.

For example, if I have this in a certain view (I'm using the Paperclip gem):

<%= image_tag @campaign.advertisement.image.url(:thumb), :class => "updateable image", 'update-from' => "campaign_advertisement_attributes_image" %>

The result in the rendered view is this:

<img alt="Stock-vector-whole" class="updateable image" src="/images/advertisements/12/thumb/stock-vector-whole.jpg?1370472026" style="display: none !important; visibility: hidden !important; opacity: 0 !important; background-position: 0px 0px;" update-from="campaign_advertisement_attributes_image" width="0" height="0">

The result is exactly the same if I manually write the img HTML in my view like so:

<img alt="Preview" class="updateable image" src="<%= @campaign.advertisement.image.url(:thumb) %>" update-from="campaign_advertisement_attributes_image">

These inline style attributes, since display is set to none and visibility to hidden, make the image invisible and override my stylesheets.

Does anyone know why these attributes are being set and how I can disable this behavior?

Thank you for any help.

like image 724
Pedro Cori Avatar asked Jan 13 '23 05:01

Pedro Cori


1 Answers

This was pretty stupid. It turns out the Ad-block plugin in my browsers was preventing the images from being visible, not something in my application. I got the idea from this other answer.

like image 111
Pedro Cori Avatar answered Jan 21 '23 14:01

Pedro Cori