Image Gravatar

A simple plugin adding the img_gravatar image link helper to ActionViews.

Install

The gem is hosted on http://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

What is a Gravatar?

A gravatar is a globally recognized avatar. It is an image hosted on the site http://site.gravatar.com, uploaded by the user and referred to on base of an eMail address. News on gravatar can be found at http://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:

<%= img_gravatar('[email protected]') %> That's me.

This will render the image of the person known under the eMail [email protected] 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:

<%= img_gravetar('[email protected]', { :size => 40, :alt => "That's me." }) %>

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#gravatar in the ImgGravatar::InstanceMethods.

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

Building a new Gem

To create a new gem, you need to install the jeweler gem (see http://blog.evanweaver.com/files/doc/fauna/echoe/files/README.html). Next, edit the Rakefile to reflect your changes, then run:

rake clobber        # remove generated stuff for a clean manifest
rake manifest       # only needed if you changed the file set
rake build_gemspec  # update the gemspec

Now, you can either publish the gem, or build a gem package. See rake -T for available targets.

Ruby 1.9

ImgGravatar version 0.2.0 and above runs on Ruby 1.9; older version will work only on Ruby 1.8.

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 http://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.