Module: Integral::LazyContentable

Extended by:
ActiveSupport::Concern
Included in:
Page, Post
Defined in:
app/models/concerns/integral/lazy_contentable.rb

Overview

Enable lazy loading WYSIWYG content

Instance Method Summary collapse

Instance Method Details

#editor_bodyString

Returns body HTML ready for WYSIWYG editor.

Returns:

  • (String)

    body HTML ready for WYSIWYG editor



12
13
14
15
16
17
18
19
20
21
# File 'app/models/concerns/integral/lazy_contentable.rb', line 12

def editor_body
  html = Nokogiri::HTML(body)

  # Remove image lazyloading
  html.css('img.lazyload').each do |element|
    element.attributes['src'].value = element.attributes['data-src'].value
  end

  html.css('body').inner_html
end