Sha256: f2f2a9108c574e16459153353b70f1d61d64e54bc326f99bbbafc88ec6377c52
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
# Usage: <%= picturefill(default_url, "AltText") do %> # <%= image(small_url) %> # <%= image(medium_url, :min => 400) %> # <%= image(medium_high_dpi_url, :min => 400, :ratio => 1.5) %> # <%= image(large_url, :min => 1000) %> # <%= image(large_high_dpi_url, "(min-width: 1000px) and (min-device-pixel-ratio: 1.5)") %> # <%= end %> module Picturefill::Rails module ViewHelper def picturefill(default_src, description, &block) raise ArgumentError.new("No Block given") unless block_given? images = Picturefill::Context.new(&block) content_tag :span, :data => { :alt => description, :picture => "" } do markup = content_tag(:span, "", :data => { :src => image_path(default_src) }).to_s images.each do |img| data = { :src => image_path(img.src) } data[:media] = img.media unless img.media.blank? markup << content_tag(:span, "", :data => data).to_s end markup << content_tag(:noscript, image_tag(default_src, :alt => description)).to_s markup end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
picturefill-0.1.1 | lib/picturefill/rails/view_helper.rb |
picturefill-0.1.0 | lib/picturefill/rails/view_helper.rb |