Skip to content

Instantly share code, notes, and snippets.

@kawarimidoll
Last active December 27, 2020 08:22
Show Gist options
  • Save kawarimidoll/4b7b6a8b6d6dc62f045031203bb7215d to your computer and use it in GitHub Desktop.
Save kawarimidoll/4b7b6a8b6d6dc62f045031203bb7215d to your computer and use it in GitHub Desktop.
Easy way to use lazy image_tag in Ruby on Rails
module ActionView::Helpers::AssetTagHelper
alias rails_image_tag image_tag
def image_tag (source, options = {})
options[:loading] ||= 'lazy'
rails_image_tag(source, options)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment