Project

avatarize

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Create nice avatars from your user's initial
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 2.0
~> 10.0
~> 3.0
 Project Readme

Avatarize

Gem Version Build Status

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.

  1. Fork the project https://github.com/rbague/avatarize/fork
  2. Run bundle and bundle exec rake
  3. Make your feature or bug fix
  4. Add tests for it. This is important so that it does not break in a future version.
  5. Submit a new Pull Request

License

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