Skip to content

Instantly share code, notes, and snippets.

@matiaskorhonen
Created November 4, 2014 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matiaskorhonen/0bfd0304e019c626fbee to your computer and use it in GitHub Desktop.
Save matiaskorhonen/0bfd0304e019c626fbee to your computer and use it in GitHub Desktop.
module ApplicationHelper
def svg_image_tag(image_name, options={})
svg_name = image_name.gsub(/#{Regexp.escape File.extname(image_name)}\z/, ".svg")
options[:onerror] = "this.onerror=null; this.src='#{asset_path(svg_name)}'"
image_tag(image_name, options)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment