Sha256: fe96a55a37d95b472df98e7bd5f04aa9a3644ef30491d52ae9d0e036ac87e4f1

Contents?: true

Size: 813 Bytes

Versions: 1

Compression:

Stored size: 813 Bytes

Contents

module RetinaImageTag
  module ViewHelpers
    
    
    def retina_image( pixel_ratio )
      image_tag(@file_dirname+"/"+@file_name+"@#{pixel_ratio}x"+@file_ext, @options)
    end
    
    
    def retina_image_tag(image, options = {})
      @devicePixelRatio = cookies[:devicePixelRatio]
      @options          = options
      
      @file_path        = image_path(image)
      @file_ext         = File.extname(@file_path)                # .jpg, .png
      @file_name        = File.basename(@file_path, @file_ext)    # pic1, foo
      @file_dirname     = File.dirname(@file_path)
      
            
      case @devicePixelRatio
        when '2'
          retina_image '2'
        when '1.5'
          retina_image '2'
        else
          image_tag(@file_path, @options)
       end
     end
     
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
retina_image_tag-0.0.6 lib/retina_image_tag/view_helpers.rb