cogDisplays a Gravatar profile image
Typewikimacro
Category
Developed by

Vincent Massol

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

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 512 px, 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 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}}
    

Get Connected