Module: LazyImageTag::ImageHelper
- Defined in:
- lib/lazy_image_tag/helpers/image_helper.rb
Instance Method Summary collapse
- #container_options(options) ⇒ Object
- #image_helper(source, options) ⇒ Object
- #image_tag_with_lazy(source, options = {}) ⇒ Object
- #link_helper(source, options) ⇒ Object
Instance Method Details
#container_options(options) ⇒ Object
8 9 10 11 12 |
# File 'lib/lazy_image_tag/helpers/image_helper.rb', line 8 def () = {} [:class] = "lazy-image-container" end |
#image_helper(source, options) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lazy_image_tag/helpers/image_helper.rb', line 24 def image_helper(source, ) custom_opts = .dup custom_opts[:data] ||= {} custom_opts[:data][:original] = source = path_to_image(source) custom_opts[:class].blank? ? custom_opts[:class] = "lazy" : custom_opts[:class] << " lazy" custom_source = path_to_image("blank.png") content = image_tag(custom_source, custom_opts) content << content_tag(:noscript, image_tag(source, )) if Rails.application.config.lazy_image_tag.js_disabled == :noscript content_tag(:div, content, ()) end |
#image_tag_with_lazy(source, options = {}) ⇒ Object
4 5 6 |
# File 'lib/lazy_image_tag/helpers/image_helper.rb', line 4 def image_tag_with_lazy(source, ={}) Rails.application.config.lazy_image_tag.js_disabled == :link ? link_helper(source, ) : image_helper(source, ) end |
#link_helper(source, options) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/lazy_image_tag/helpers/image_helper.rb', line 14 def link_helper(source, ) [:class].blank? ? [:class] = "lazy-image-link" : [:class] << " lazy-image-link" [:data] ||= {} [:data][:width] = [:width] [:data][:height] = [:height] [:data][:id] = [:id] [:alt] = [:width] = [:height] = [:id] = nil content_tag(:div, link_to([:alt], path_to_image(source), ), ()) end |