mirror of https://github.com/rails/rails
Merge pull request #23288 from bdewater/sprockets3-sha2-alt
Fix img alt attribute generation when using Sprockets >= 3.0
This commit is contained in:
parent
e8eda76893
commit
98a01c6f01
|
@ -1,3 +1,8 @@
|
|||
* Fix stripping the digest from the automatically generated img tag alt
|
||||
attribute when assets are handled by Sprockets >=3.0.
|
||||
|
||||
*Bart de Water*
|
||||
|
||||
* Generate `week_field` input values using a 1-based index and not a 0-based index
|
||||
as per the W3 spec: http://www.w3.org/TR/html-markup/datatypes.html#form.data.week
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ module ActionView
|
|||
# image_alt('underscored_file_name.png')
|
||||
# # => Underscored file name
|
||||
def image_alt(src)
|
||||
File.basename(src, '.*').sub(/-[[:xdigit:]]{32}\z/, '').tr('-_', ' ').capitalize
|
||||
File.basename(src, '.*').sub(/-[[:xdigit:]]{32,64}\z/, '').tr('-_', ' ').capitalize
|
||||
end
|
||||
|
||||
# Returns an html video tag for the +sources+. If +sources+ is a string,
|
||||
|
|
|
@ -448,6 +448,7 @@ class AssetTagHelperTest < ActionView::TestCase
|
|||
[nil, '/', '/foo/bar/', 'foo/bar/'].each do |prefix|
|
||||
assert_equal 'Rails', image_alt("#{prefix}rails.png")
|
||||
assert_equal 'Rails', image_alt("#{prefix}rails-9c0a079bdd7701d7e729bd956823d153.png")
|
||||
assert_equal 'Rails', image_alt("#{prefix}rails-f56ef62bc41b040664e801a38f068082a75d506d9048307e8096737463503d0b.png")
|
||||
assert_equal 'Long file name with hyphens', image_alt("#{prefix}long-file-name-with-hyphens.png")
|
||||
assert_equal 'Long file name with underscores', image_alt("#{prefix}long_file_name_with_underscores.png")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue