Method: Jekyll::Assets::HTML::IMG#complex

Defined in:
lib/jekyll/assets/plugins/html/img.rb

#complex(doc) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jekyll/assets/plugins/html/img.rb', line 24

def complex(doc)
  img = doc.img @args.to_h(html: true, skip: HTML.skips)
  Array(args[:srcset][:width]).each do |w|
    dimensions, density, type = w.to_s.split(%r!\s+!, 3)

    img["srcset"] ||= ""
    img["srcset"] += ", #{path(dimensions: dimensions, type: type)} "
    img["srcset"] += density || "#{dimensions}w"
    img["srcset"] = img["srcset"]
      .gsub(%r!^,\s*!, "")
  end
end