Skip to content

Instantly share code, notes, and snippets.

@flexbox
Last active December 29, 2016 21:20
Show Gist options
  • Save flexbox/6932472 to your computer and use it in GitHub Desktop.
Save flexbox/6932472 to your computer and use it in GitHub Desktop.
[ruby on rails] - Image helper for retina display with foundation interchange
module ApplicationHelper
def retina_image_tag(default_name, options={})
retina_name = default_name.gsub(%r{\.\w+$}, '@2x\0')
retina_image_tag(default_name, options.merge('data-interchange' => "[#{asset_path(retina_name)}, (retina)]"))
end
end
= image_tag('front/static/logo.png', alt: 'Description', 'data-interchange' => "[#{image_path('front/static/logo@2x.png')}, (retina)]")
<img src="/assets/front/static/global/logo.png" data-interchange="[/assets/front/static/global/logo@2x.png, (retina)]" alt="Description">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment