Class: Imgix::Rails::PictureTag
- Includes:
- ActionView::Context
- Defined in:
- lib/imgix/rails/picture_tag.rb
Instance Method Summary collapse
-
#initialize(source, options, default_options, breakpoints) ⇒ PictureTag
constructor
A new instance of PictureTag.
- #render ⇒ Object
Methods inherited from Tag
available_parameters, parameters
Methods included from UrlHelper
Constructor Details
#initialize(source, options, default_options, breakpoints) ⇒ PictureTag
Returns a new instance of PictureTag.
7 8 9 10 11 12 |
# File 'lib/imgix/rails/picture_tag.rb', line 7 def initialize(source, , , breakpoints) @source = source = = @breakpoints = breakpoints end |
Instance Method Details
#render ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/imgix/rails/picture_tag.rb', line 14 def render content_tag(:picture, ) do @breakpoints.each do |media, opts| html_opts = opts.except(*self.class.available_parameters) html_opts[:media] ||= media html_opts[:srcset] ||= srcset(.clone.merge(opts)) concat(content_tag(:source, nil, html_opts)) end concat Imgix::Rails::ImageTag.new(@source, ).render end end |