Skip to content

Instantly share code, notes, and snippets.

@mrmemes-eth
Forked from superacidjax/view_helpers.rb
Created July 16, 2012 14:07
Show Gist options
  • Save mrmemes-eth/3122908 to your computer and use it in GitHub Desktop.
Save mrmemes-eth/3122908 to your computer and use it in GitHub Desktop.
module ClearEyes
module ViewHelpers
def self.included(base)
base.send(:attr_accessor, :image, :options)
end
def r_image( pixel_ratio )
insert_on = -File.extname(self.image).size-1
image_tag(self.image.insert(insert_on, "@#{pixel_ratio}x"), self.options)
end
def r_image_tag(image, options = {})
self.options = options
self.image = image
case cookies[:devicePixelRatio]
when '2'
r_image 2
when '1.5'
r_image 2
else
image_tag(self.image, self.options)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment