rails_picture
Simple picture_tag helper, which can show various image formats based on browser support
About The Project
Provide a new helper method to Rails views - picture_tag
It generates a <picture>
HTML tag and within it places HTML tag as <img>
and any other available image formats as <source>
tags.
Internally it uses Rails built-in method image_tag
.
Installation
Add this line to your application's Gemfile:
gem 'rails_picture'
And then execute in terminal:
bundle install
Usage
-
Put multiple same-named images with different file formats into
app/assets/images/
-
Place following code into any Rails view. It takes the same options as Rails built in
image_tag
:
picture_tag(filename, **options)
Note - do not input file extension in filename
Roadmap
See the TODO for status of current development.
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run bundle exec rake
to run the tests, rubocop. You can also run bin/console
for an interactive prompt that will allow you to experiment.
License
The gem is available as open source under the terms of the MIT License.
Conduct
Project Link: https://github.com/OskarsEzerins/rails_picture
Everyone interacting in the rails_picture project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.