12 lines
272 B
Ruby
12 lines
272 B
Ruby
require 'nokogiri'
|
|
|
|
module LazyImages
|
|
def lazy_images(content)
|
|
fragment = Nokogiri::HTML::DocumentFragment.parse(content)
|
|
fragment.css('img').each { |image| image['loading'] = 'lazy' }
|
|
fragment.to_html
|
|
end
|
|
end
|
|
|
|
Liquid::Template.register_filter(LazyImages)
|