Gravatar Macro

Version 12.12 by Vincent Massol on 2013/09/05 08:28

cogDisplays a Gravatar profile image
TypeXAR
Category
Developed by

Vincent Massol

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager

Description

Display a Gravatar profile image.

Usage

{{gravatar email="email" size="size" default="default"/}}

Where:

ParameterOptionalValue
emailNoEmail value, e.g. [email protected]
sizeYesFrom 1px to 512px, e.g. "50"
defaultYesImage to use when no profile is found for the passed email. Valid values are: "mm", "identicon", "monsterid", "wavatar", "retro" or an URL-encoded URL to an image. See the Gravatar documenation for more details.

Example

{{gravatar email="[email protected]" size="100" default="monsterid"/}}

Result

gravatar.png

Source Code

For those interested, here's the macro source code:

{{groovy}}
def hash = org.apache.commons.codec.digest.DigestUtils.md5Hex(xcontext.macro.params.email)
def url = "image:http://www.gravatar.com/avatar/${hash}"

def size = xcontext.macro.params.size
if (size) {
 url = "${url}?s=${size}"
}

def d = xcontext.macro.params.default
if (size && d) {
 url = "${url}&d=${d}"
} else if (size) {
 url = "${url}?d=${d}"
}

println url
{{/groovy}}

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Release Notes

v1.0

Initial version

    

Get Connected