Sha256: edd95b5f548e05daa5535c503b8a0e6c72fa7abeb74d02a4d1f308a6066c3e3e
Contents?: true
Size: 946 Bytes
Versions: 17
Compression:
Stored size: 946 Bytes
Contents
module PictureTag module Srcsets # Creates a srcset in the "(filename) (width)w, (...)" format. # Example: "img.jpg 400w, img2.jpg 600w, img3.jpg 800w" class Width < Basic # Sizes html attribute. Since it's intimately related to srcset, we # generate it at the same time. def sizes preset_sizes = PictureTag.preset['sizes'] || {} preset_size = PictureTag.preset['size'] size_set = [] preset_sizes.each_pair do |media, size| size_set << build_size_entry(media, size) end size_set << preset_size if preset_size size_set.any? ? size_set.join(', ') : nil end private def widths PictureTag.widths(@media) end def build_srcset_entry(file) "#{file.uri} #{file.width}w" end def build_size_entry(media, size) "(#{PictureTag.media_presets[media]}) #{size}" end end end end
Version data entries
17 entries across 17 versions & 1 rubygems