So apparently this commit adds a configuration option to define the default value of the image_tag :loading option. Thus by setting, config.action_view.image_loading an application can opt in to lazy loading images sitewide, without changing view code.
config.action_view.image_loading = "lazy"
However when I try to add it to my development.rb or production.rb I get the following error :
1: from /Users/cash/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionview-126.96.36.199/lib/action_view/railtie.rb:46:in `each' /Users/cash/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionview-188.8.131.52/lib/action_view/railtie.rb:53:in `block (3 levels) in <class:Railtie>': undefined method `image_loading=' for ActionView::Base:Class (NoMethodError)
Rails version: 184.108.40.206
Ruby version: ruby 2.7.1p83
This is not yet available in stable rails, it will be available in rails 7, and if you need to do it now, you can switch to depend on the git main head:
git 'https://github.com/rails/rails.git' do gem 'railties' gem 'actionpack' gem 'activemodel' end
You can see it by going to the merge commit: https://github.com/rails/rails/commit/3c2a80d8b1d4730897a7040b7f563d0027aa1e83 and checking just below the title. It shows the branches and tags this commit belongs to (in this case, only