Skip to content

Commit 60c8a03

Browse files
committed
Remove deprecated image_alt helper
1 parent e70d3df commit 60c8a03

File tree

3 files changed

+4
-43
lines changed

3 files changed

+4
-43
lines changed

actionview/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated `image_alt` helper.
2+
3+
*Rafael Mendonça França*
4+
15
* Fix the need of `#protect_against_forgery?` method defined in
26
`ActionView::Base` subclasses. This prevents the use of forms and buttons.
37

actionview/lib/action_view/helpers/asset_tag_helper.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -355,29 +355,6 @@ def image_tag(source, options = {})
355355
tag("img", options)
356356
end
357357

358-
# Returns a string suitable for an HTML image tag alt attribute.
359-
# The +src+ argument is meant to be an image file path.
360-
# The method removes the basename of the file path and the digest,
361-
# if any. It also removes hyphens and underscores from file names and
362-
# replaces them with spaces, returning a space-separated, titleized
363-
# string.
364-
#
365-
# ==== Examples
366-
#
367-
# image_alt('rails.png')
368-
# # => Rails
369-
#
370-
# image_alt('hyphenated-file-name.png')
371-
# # => Hyphenated file name
372-
#
373-
# image_alt('underscored_file_name.png')
374-
# # => Underscored file name
375-
def image_alt(src)
376-
ActiveSupport::Deprecation.warn("image_alt is deprecated and will be removed from Rails 6.0. You must explicitly set alt text on images.")
377-
378-
File.basename(src, ".*").sub(/-[[:xdigit:]]{32,64}\z/, "").tr("-_", " ").capitalize
379-
end
380-
381358
# Returns an HTML video tag for the +sources+. If +sources+ is a string,
382359
# a single video tag will be returned. If +sources+ is an array, a video
383360
# tag with nested source tags for each source will be returned. The

actionview/test/template/asset_tag_helper_test.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -512,26 +512,6 @@ def test_url_to_image_alias_for_image_url
512512
UrlToImageToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
513513
end
514514

515-
def test_image_alt
516-
[nil, "/", "/foo/bar/", "foo/bar/"].each do |prefix|
517-
assert_deprecated do
518-
assert_equal "Rails", image_alt("#{prefix}rails.png")
519-
end
520-
assert_deprecated do
521-
assert_equal "Rails", image_alt("#{prefix}rails-9c0a079bdd7701d7e729bd956823d153.png")
522-
end
523-
assert_deprecated do
524-
assert_equal "Rails", image_alt("#{prefix}rails-f56ef62bc41b040664e801a38f068082a75d506d9048307e8096737463503d0b.png")
525-
end
526-
assert_deprecated do
527-
assert_equal "Long file name with hyphens", image_alt("#{prefix}long-file-name-with-hyphens.png")
528-
end
529-
assert_deprecated do
530-
assert_equal "Long file name with underscores", image_alt("#{prefix}long_file_name_with_underscores.png")
531-
end
532-
end
533-
end
534-
535515
def test_image_tag
536516
ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
537517
end

0 commit comments

Comments
 (0)