Sha256: 4212685a33d88879535f93100eb312dbe154a55c41a938f572bd4570b574a098

Contents?: true

Size: 626 Bytes

Versions: 3

Compression:

Stored size: 626 Bytes

Contents

module RetinaImageTag
  module ViewHelpers
    
    def retina_image( pixel_ratio )
      insert_on = -File.extname(@image).size-1
      image_tag(@image.insert(insert_on, "@#{pixel_ratio}x"), @options)
    end
    
    
    def retina_image_tag(image, options = {})
      @devicePixelRatio = cookies[:devicePixelRatio]
      @options          = options
      @image            = image             # foo.jpg, subdir/foo.png

      case @devicePixelRatio
        when '2'
          retina_image 2
        when '1.5'
          retina_image 2
        else
          image_tag(@image, @options)
       end
     end
     
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
retina_image_tag-1.0.0 lib/retina_image_tag/view_helpers.rb
retina_image_tag-0.0.13 lib/retina_image_tag/view_helpers.rb
retina_image_tag-0.0.10 lib/retina_image_tag/view_helpers.rb