Integrates Retina.js with the rails asset pipeline.
Retina.js is an awesome and simple plugin for rendering retina images for displays that support this.
Add this line to your application's Gemfile:
gem "retinajs-rails", "~> 2.1.1"
And then execute:
$ bundle
To import the js plugin, add the following line to your application.js:
//= require retina
Now you will be able to render retina images by using the image_tag_with_at2x
helper. Example:
# Replace:
image_tag "logo.png"
# With:
image_tag_with_at2x "logo.png"
This will output the HTML similar to:
<img data-rjs="/assets/logo@2x.png" src="/assets/logo.png">
If you'd like to use the SCSS mixin, you need to import retina.scss
, add the following line to your application.scss:
@import "retina"
Now you're able to use the .at2x
mixin in your stylesheets.
For example:
.logo {
@include retina('logo.png');
}
will compile to something that resembles:
.logo {
background-image: url('logo.png');
}
@media all and (-webkit-min-device-pixel-ratio: 1.5) {
.logo {
background-image: url('logo@2x.png');
}
}
For more information about Retina.js, see: http://imulus.github.io/retinajs/
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request