Gravatar Component class
ViewComponent to generate an IMG tag for a Gravatar icon.
public class GravatarComponent
Remarks
ViewComponent to generate IMG tag for a user-specific Gravatar icon, based on the user's email address.
Gravatar ("Globally Recognized Avatar"; http://en.gravatar.com
) is a service which allows users to associate a personal icon (avatar) to their email address, and displays that avatar when requested. This allows blogs and other websites which know a users email address to display their personal avatar next to their comments. For users who have not registered an icon, a graphic pattern based on a hash of their email address can be displayed, so all people can have a personal icon which is consistent across websites.
There are three separate APIs for this functionality.
- Through the ViewComponent described here, for use in Views
- Through the static CreateImgTag method in GravatarHelper, for use in Controllers.
- Through any of the instance CreateImgTag methed overloads in GravatarHelper, for use in wherever convenient.
GravatarViewComponent is a line component with one required and five optional parameters.
| Section | Description |
|---|---|
| The email address for the user for whom you want the Gravatar icon. String, Required. | |
| Size | Size, in pixel of the desired icon. (Icon is square so Size applies to both height & width) Integer, Optional, defaults to 80 pixels |
| DefaultImage | The image to display, if the email address does not have an image registered with Gravatar.com. Either the fully-qualified URL to an image to use, |
| OutputGravatarSiteLink | Wraps the IMG tag in an A tag which links to gravatar.com, so users can get their own avatar. Bool, defaults to true. |
| LinkTitle | Text for the title= attribute of the A tag wrapping the image. Displays as a tool tip. String, optional, defaults to "Get your avatar". Used only if OutputGravatarSiteLink is set to true. |
| MaxAllowedRating | String, one of "G", "PG", "R", "X". Defaults to "G" (See descriptions below) |
| Default Image keywords | Description |
|---|---|
| identicon | A randomly generated assortment of shapes, reflected to be symetrical (based on the work of Don Park, http://donpark.wordpress.com/2007/01/18/visual-security-9-block-ip-identification |
| monsterid | A monster is created from the following parts: body (10 different), arms(5), legs(5), eyes (10), mouth(10) and hair(5). (based on the work of Andreas Gohr, http://www.splitbrain.org/projects/monsterid |
| wavatar | Can best be described as geometric shapes with faces. (based on the work of Shamus Young, http://www.shamusyoung.com/twentysidedtale/?p=1462 |
| MaxAllowedRating options | Description |
|---|---|
| G | Suitable for display on all websites with any audience type. |
| PG | May contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence. |
| R | May contain such things as harsh profanity, intense violence, nudity, or hard drug use. |
| X | May contain hardcore sexual imagery or extremely disturbing violence. |
Example
#component(Gravatar with "Email=jamescurran@mvps.org" "Size=40")
will generate HTML like this:
<a href="http://www.gravatar.com" title="Get your avatar"> <img src="http://www.gravatar.com/avatar/98df3c7cc17f088af555c5accbdb2509.jpg?rating=G&size=40" alt="Gravatar" width="40" height="40"> </a>
