This is a simple, clean plugin to display gravatars in comment forms. It doesn’t use any cache and provides access to all Gravatar options.
It outputs an
<img> tag. If wanted, the image can be linked to the commenter’s website.
Why another gravatar plugin ?
Just because the existing one was too complex for my needs (using a caching library, etc.) and I wanted a straightforward implementation, and also because I wanted the functionality of linking the gravatar image to the commenter’s website if the commenter provided it. It is actually possible to link an image with
<txp:comment_web />, but then the link is displayed in all cases, even if the commenter entered no website address. This plugin creates the link only if the commenter entered its website address.
In a comment form:
- default: Absolute URL of the default image to display when the commenter has no gravatar. This default image is never resized, so make sure it has the same size as
size(see below) for a consistent display. When not specified, Gravatar will return a 1×1 pixel GIF image.
- size: The square size of the gravatar image, in pixels (numeric value in the range 1 to 80). Gravatar will resize the default 80×80 pixels image to this size, using bicubic resizing. When not specified, it will return the image in its original size of 80×80 pixels.
- rating: Either ‘G’, ‘PG’, ‘R’ or ‘X’. The commenter’s gravatar will be displayed if it does not exceed the specified rating, otherwise the default image will be shown (see above). By default, all gravatars are shown without restriction.
- border: Hexadecimal value of the color of a 1px border to be overlaid on the gravatar (example: FF0000). Default is no added border.
- alt: Alternative text for the image. Default is empty.
- class: CSS class attribute for the
<img>tag, default is no class attribute.
- link: When set to
true, the image will be linked to the commenter’s website (if available). The link will have a “nofollow” attribute if specified in the Textpattern advanced options. Default is
- Code cleaning, no more warnings.
- Now the plugin sets the “width” and “height” attributes on the XHTML img tag, for a more coherent display during image loading.
- Code cleaning.