Avatarize
Gem to create letter avatars from users name (or any string). It uses HTML canvas to generate the image (base64).
Based on Lee Crossley's gist
Installation
Add this line to your application's Gemfile
:
gem 'avatarize'
Add the following to application.js
:
//= require avatarize
window.addEventListener("turbolinks:load", Avatarizer.processAll);
// Or this if not uing turbolinks
window.addEventListener("load", Avatarizer.processAll);
Usage
To create an avatar:
<%= avatar_tag 'Avatarize' %>
# Custom size
<%= avatar_tag 'Avatarize', 200 %>
# Other html attributes
<%= avatar_tag 'Avatarize', nil, class: 'rounded-circle', title: 'Avatar' %>
Contributing
Bug reports and pull requests are welcome.
- Fork the project https://github.com/rbague/avatarize/fork
- Run
bundle
andbundle exec rake
- Make your feature or bug fix
- Add tests for it. This is important so that it does not break in a future version.
- Submit a new Pull Request
License
The gem is available as open source under the terms of the MIT License.