Permalink
Browse files

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.
  • Loading branch information...
1 parent 8ad8f61 commit 4dd4621f5bb5500092e635e80e1b1cb1d888b6ec @josevalim josevalim committed with rafaelfranca May 18, 2012
@@ -272,7 +272,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
@@ -358,7 +358,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
@@ -164,6 +164,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 = {

0 comments on commit 4dd4621

Please sign in to comment.