Image Gravatar¶ ↑
A simple plugin adding the img_gravatar
image link helper to ActionViews. The plugin is meant for Ruby on Rails and does require 'actionpack'
to work.
Install¶ ↑
The gem is hosted on gemcutter.org, which is the default Ruby gem hoster at this time (November 2009). All you need to install the latest version is run the following command:
gem install img_gravatar
The latest version of img_gravatar can be found at github.com/tsalzer/img_gravatar
Please use the issue tracker there for any bug reports.
What is a Gravatar?¶ ↑
A gravatar is a globally recognized avatar. It is an image hosted on the site site.gravatar.com, uploaded by the user and referred to on base of an eMail address. News on gravatar can be found at blog.gravatar.com.
Each gravatar image can be rated with respect to its content being suitable for a given audience. You might want to use the rating feature if you run a public site.
Usage¶ ↑
To use a gravatar on your system, your view needs the eMail address of the individual to be displayed. The most simple case is like this:
<p> <%= img_gravatar('me@email.com') %> That's me. </p>
This will render the image of the person known under the eMail me@email.com in your browser. If there is no person known with this name, it will render the Gravatar logo.
A more complex szenario would include a size definition, and an alt image tag:
<p> <%= img_gravetar('me@email.com', { :size => 40, :alt => "That's me." }) %> </p>
This would render a downsized image of 40x40 with the alt-tag “That’s me.”.
For a complete description of available parameters see ImgGravatar::InstanceMethods#img_gravatar
in the ImgGravatar::InstanceMethods
module.
Configuration Options¶ ↑
You can modify the following aspects of the displayed gravatar image:
* :alt - the alternative text for this image * :default_url - the default URL for this gravatar * :size - the requested gravatar size * :rating - the requested maximum rating
The alt and size information will be reflected in the image tag.
The size of the image is limited by gravatar.com to a maximum of 512 pixel each side. This code will fallback to default size if the requested size is larger than 512 pixel, or smaller than 1 pixel. (It might be argued that a 1-pixel-gravatar is quite useless, but you have to draw the line somewhere. Besides, gravatar.com tells us pixel size 1 is legal.)
Note: The size attribute is not really required to be set here, since the actual image will be rendered by gravatar.com and we cannot really control which image size will be delivered. However, we will tell the browser how to scale the image.
Development¶ ↑
To create a new gem, you need to install the jeweler gem (see github.com/technicalpickles/jeweler/). Usually you just have to run
gem install jeweler
Then you may check the remaining dependencies with
rake check_dependencies:development
See rake -T
for available targets.
Building a new Gem¶ ↑
Building a new gem is easy since Jeweler, just run
rake build_gemspec # update the gemspec rake install # build and install the actual gem
Ruby 1.9 Compatibility¶ ↑
ImgGravatar version 0.2.0 and above runs on Ruby 1.9, Ruby 1.8 and JRuby 1.4.0; older version will work only on Ruby 1.8 (not tested on JRuby, failed on Ruby 1.9).
Bugs¶ ↑
If you encounter bugs in img_gravatar, please use the issue tracker at github.com/tsalzer/img_gravatar/issues
Alternatives¶ ↑
There are lots of other Gravatar plugins out there; find some Ruby on Rails plugins at en.gravatar.com/site/implement/rails. Of course I encourage you to use and improve this plugin. :)
License¶ ↑
The img_gravatar gem comes to you under the MIT License. You should find the license text in the file MIT-LICENSE in the gem folder.
The img_gravatar gem is not affiliated with the Gravatar service. Usage terms of the Gravatar service should be looked up at gravatar.com.
Please note that changes to the Gravatar API or their terms of service or the cease of Gravatar service may result in breaking the img_gravatar gem functionality. This is considered out of the responsibility of the author of the img_gravatar gem.