0.0
No commit activity in last 3 years
No release in over 3 years
A simple retina image tag
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 5.0.2
 Project Readme

RetinaImage

Retina Image is a simple retina image tag that supports high resolution images using assets pipeline. It will find the suitable image for any resolution for you. Also, this gem does not override your original image_tag.

Installation

Add this line to your application's Gemfile:

gem 'retina_image'

And then execute:

$ bundle

Or install it yourself as:

$ gem install retina_image

Usage

Include module in your application helper or any helper in your app

include RetinaImage::ViewHelpers

Add images as example_1x.png, example_2x.png, example_3x.png to your asset pipeline then add below code to your view.

<%= retina_image_tag 'example.png' %>

Output

<img srcset="/example_1x.png 1x, /example_2x.png 2x, /example_3x.png 3x" alt="Example" src="/example_1x.png">

Add other options. For example

<%= retina_image_tag 'example.png', alt: 'Example Wow' %>

Output

<img srcset="/example_1x.png 1x, /example_2x.png 2x, /example_3x.png 3x" alt="Example Wow" src="/example_1x.png">

Disable retina image tag by adding include_srcsets: false

<%= retina_image_tag 'example.png', include_srcsets: false%>

Output

<img src="/example_1x.png" alt="Example" >

Contributing

Create pull requests. Raise issues.

License

The gem is available as open source under the terms of the MIT License.