Module: LazyImages::Rails::TagHelper

Defined in:
lib/lazy_images/rails/tag_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
# File 'lib/lazy_images/rails/tag_helper.rb', line 8

def self.included(base)
  base.alias_method_chain :image_tag, :lazy_images
end

Instance Method Details

#image_tag_with_lazy_images(source, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lazy_images/rails/tag_helper.rb', line 12

def image_tag_with_lazy_images(source, options={})
  options.merge!(
    class: "#{options[:class]} rli-image",
    src: path_to_image(source)
  )

  placeholder = LazyImages::Rails::Placeholder.new(
    LazyImages::Rails.placeholder, options
  )

  (:div, class: 'rli-wrapper') do
    placeholder.to_s.html_safe +
      image_tag_without_lazy_images(source, options)
  end
end