提交 6bb86e1f 编写于 作者: J José Valim

Merge pull request #5020 from KL-7/fix-blank-image_tag-source

Render img tag with empty src if empty string is passed to image_tag.
......@@ -274,7 +274,7 @@ def favicon_link_tag(source='favicon.ico', options={})
# The alias +path_to_image+ is provided to avoid that. Rails uses the alias internally, and
# plugin authors are encouraged to do so.
def image_path(source)
asset_paths.compute_public_path(source, 'images')
source.present? ? asset_paths.compute_public_path(source, 'images') : ""
end
alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
......@@ -377,7 +377,7 @@ def image_tag(source, options={})
src = options[:src] = path_to_image(source)
unless src =~ /^(?:cid|data):/
unless src =~ /^(?:cid|data):/ || src.blank?
options[:alt] = options.fetch(:alt){ image_alt(src) }
end
......
......@@ -205,6 +205,7 @@ def teardown
%(image_tag("//www.rubyonrails.com/images/rails.png")) => %(<img alt="Rails" src="//www.rubyonrails.com/images/rails.png" />),
%(image_tag("mouse.png", :alt => nil)) => %(<img src="/images/mouse.png" />),
%(image_tag("data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==", :alt => nil)) => %(<img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" />),
%(image_tag("")) => %(<img src="" />)
}
FaviconLinkToTag = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册