1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Improve changelog entry from #9221 [ci skip]

This commit is contained in:
Carlos Antonio da Silva 2013-02-11 11:37:17 -02:00
parent 7765ee0e47
commit b1c72a3675
2 changed files with 16 additions and 18 deletions

View file

@ -1,23 +1,21 @@
## Rails 4.0.0 (unreleased) ##
* Fix `image_alt` method to work with underscored or hyphenated file names.
Currently, underscored filenames become
`<img alt="A_long_file_name_with_underscores"` in HTML, which is
poor for accessibility; Apple's VoiceOver Utility pronounces
each underscore. "A_long_file_name" thus becomes "A underscore
long underscore file underscore name." This patch makes underscored
or hyphenated file names (both of which are very popular naming
conventions) read more naturally in screen readers by converting
both hyphens and underscores to spaces.
* Change `image_alt` method to replace underscores/hyphens to spaces in filenames.
Example:
# current implementation
image_tag('underscored_file_name.png')
#=> <img alt="Underscored_file_name" src="/assets/underscored_file_name.png" />
Previously, underscored filenames became `alt="A_long_file_name_with_underscores"`
in HTML, which is poor for accessibility. For instance, Apple's VoiceOver Utility
pronounces each underscore. `A_long_file_name` thus would be read as `A underscore
long underscore file underscore name.` Now underscored or hyphenated filenames
(both of which are very popular naming conventions) read more naturally in
screen readers by converting both hyphens and underscores to spaces.
# this patch
Before:
image_tag('underscored_file_name.png')
#=> <img alt="Underscored file name" src="/assets/underscored_file_name.png" />
# => <img alt="Underscored_file_name" src="/assets/underscored_file_name.png" />
After:
image_tag('underscored_file_name.png')
# => <img alt="Underscored file name" src="/assets/underscored_file_name.png" />
*Nick Cox*

View file

@ -215,11 +215,11 @@ module ActionView
# Returns a string suitable for an html image tag alt attribute.
# The +src+ argument is meant to be an image file path.
# The method removes the basename of the file path and the digest,
# The method removes the basename of the file path and the digest,
# if any. It also removes hyphens and underscores from file names and
# replaces them with spaces, returning a space-separated, titleized
# string.
#
#
# ==== Examples
#
# image_tag('rails.png')
@ -227,7 +227,7 @@ module ActionView
#
# image_tag('hyphenated-file-name.png')
# # => <img alt="Hyphenated file name" src="/assets/hyphenated-file-name.png" />
#
#
# image_tag('underscored_file_name.png')
# # => <img alt="Underscored file name" src="/assets/underscored_file_name.png" />
def image_alt(src)