Module: ImageHelpers
- Defined in:
- lib/image_helpers.rb,
lib/image_helpers/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
Instance Method Details
#picture_tag(images) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/image_helpers.rb', line 6 def picture_tag(images) return if images.empty? sources = images.select {|uri| uri[:media] } image = images.find {|uri| !uri[:media] } content_tag :picture do sources.each do |source| url = resolve_path_to_image(source.delete(:url)) concat tag(:source, {srcset: url}.merge(source)) end concat image_pack_tag(image.delete(:url), image) end end |
#svg_sprite(name, link, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/image_helpers.rb', line 22 def svg_sprite(name, link, = {}) name = "#{name}.svg" unless name.end_with?(".svg") entry = current_webpacker_instance.config.source_entry_path.basename.to_s url = asset_pack_path("media/#{entry}/images/#{name}") [:role] ||= "presentation" content_tag :svg, do tag.use href: "#{url}##{link}" end end |