Sha256: a57734a1d6a3802f7c4c0c6ce7445f54ec8921f38560b83214426d541bdee641

Contents?: true

Size: 753 Bytes

Versions: 1

Compression:

Stored size: 753 Bytes

Contents

module PictureHelper
  def picture_tag(path, options = {})

    content_tag(:picture, options) do
      concat content_tag  :source,
                          nil,
                          srcset: "#{path}.webp",
                          type: "image/webp",
                          style: "height: inherit; width: inherit" if File.exist?(Rails.root.join("public/#{path}.webp"))
      concat content_tag  :source,
                          nil,
                          srcset: "#{path}.jpg",
                          type: "image/jpeg",
                          style: "height: inherit; width: inherit" if File.exist?(Rails.root.join("public/#{path}.jpg"))
      concat image_tag path, style: "height: inherit; width: inherit"
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carrierwave-picture-0.1.0 lib/carrierwave-picture/picture_helper.rb