Every repository with this icon (
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Thu Sep 24 00:20:05 -0700 2009 | |
| |
MIT-LICENSE | Fri Sep 04 07:59:02 -0700 2009 | |
| |
README.textile | Sun Sep 27 20:57:21 -0700 2009 | |
| |
init.rb | Wed Sep 23 14:40:44 -0700 2009 | |
| |
lib/ | Thu Sep 24 00:20:05 -0700 2009 | |
| |
spec/ | Thu Sep 24 00:20:05 -0700 2009 |
![]()
Gravatar Image Tag Plugin
Rails view helper for grabbing Gravatar images. The goal here is to be configurable and have those configuration points documented!
Install as a Ruby on Rails Plugin
The traditional way.
./script/plugin install git://github.com/mdeering/gravatar_image_tag.git
or the old-school but still c00l way!
piston import git://github.com/mdeering/gravatar_image_tag.git vendor/plugins/gravatar_image_tag
or for all you hip gitsters.
git submodule add git://github.com/mdeering/gravatar_image_tag.git vendor/plugins/gravatar_image_tag git submodule init
Usage
Once you have installed it as a plugin for your rails app usage is simple.
gravatar_image_tag('spam@spam.com'.gsub('spam', 'mdeering'), :alt => 'Michael Deering')
Boom here is my gravatar
Configuration Points
Setting the default image
If no default image is given in either an initializer or through the options passed to the gravatar_image_tag then the default image from the gravatar site will be displayed.
gravatar_image_tag('junk', :alt => 'Default Gravatar Image')
Splat the default gravatar image
You can specify the default image through an initializer as follows:
# config/initializers/gravatar_defaults.rb ActionView::Base.default_gravatar_image = 'http://assets.yourhost.com/images/default_gravatar.png'
You can also specify the default image to fallback to or override the one set in the above initializer by passing the :gravatar => { :default => ‘http://assets.yourhost.com/images/override_gravatar.png’ } option to the gravatar_image_tag call. All other options will be forwarded onto the image_tag.
gravatar_image_tag('junk', :alt => 'Github Default Gravatar', :gravatar => { :default => 'http://github.com/images/gravatars/gravatar-80.png' })
Ka-Pow ![]()
Setting the default image size
If no default image size is given in either the plugin configuration or through the options passed to the gravatar_image_tag then the default image size from the gravatar site will be displayed (80px x 80px at the time of this writing).
You can specify your default image size through the plugin configuration by adding the following line to your rails environment.
# config/initializers/gravatar_defaults.rb ActionView::Base.default_gravatar_size = 120
You can also specify the image size or override the one set in the plugin configuration by passing the :gravatar => { :size => 50 } option to the gravatar_image_tag call. All other options will be forwarded on to the image_tag call.
gravatar_image_tag('spam@spam.com'.gsub('spam', 'mdeering'), :alt => 'Michael Deering', :class => 'some-class', :gravatar => { :size => 15 })
Mini Me!
Credits
The ideas an methods for this plugin are from expanding upon my original blog post Adding Gravatar To Your Website Or Blog
Copyright © 2009 Michael Deering, released under the MIT license







