This project is archived and is in readonly mode.
sending :alt => nil to an image tag should omit the images alt tag
Reported by Jeff Dean | May 9th, 2010 @ 06:08 AM | in 3.0.2
I have an app where I set the alt tag of images with javascript. To reduce the size of the page, I want to emit img tags with no alt attribute, however that is not currently possible:
image_tag "foo.png", :alt => nil # => <img alt="Foo" src="/images/foo.png" />
I agree that images should have alt tags, and I agree that the default is sensible. However, if I explicitly send :alt => nil, I expect it to omit the alt attribute altogether, to be consistent with :class and other html attributes.
I plan to submit a patch momentarily.
Comments and changes to this ticket
-
Jeff Dean May 9th, 2010 @ 06:10 AM
- Tag changed from action_view to action_view, patch
-
Dan Pickett May 9th, 2010 @ 05:51 PM
- Tag changed from action_view, patch to action_view, bugmash, patch
-
Marc-André Lafortune May 9th, 2010 @ 09:19 PM
Hi Jeff!
I'd recommend using the block form of fetch, to avoid an unnecessary calculation in case the :alt option is specified. Modified diff attached.
-
Jeff Dean May 10th, 2010 @ 02:36 AM
- Tag cleared.
And thanks for Marc-Andre for introducing me to fetch last year! I forgot about the block syntax.
-
José Valim May 10th, 2010 @ 11:12 AM
- Milestone cleared.
- Assigned user set to José Valim
-
Repository May 15th, 2010 @ 08:51 AM
- State changed from new to resolved
(from [9869ee77cdbf8f0e9c7eb6e33738d0aa8f5dc70a]) Accept :alt => nil on image_tag [#4558 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/9869ee77cdbf8f0e9c7eb6e33738d0... -
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Tag set to 3, documentation, patch, review
- Milestone set to 3.0.2
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 4558 sending :alt => nil to an image tag should omit the images alt tag (from [9869ee77cdbf8f0e9c7eb6e33738d0aa8f5dc70a]) Accept ...