Gravatar Macro
Version 9.1 by Thomas Mortagne on 2011/10/27 19:24
Displays a Gravatar profile image |
Type | wikimacro |
Category | |
Developed by | Vincent Massol |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Display a Gravatar profile image.
Usage
{{gravatar email="email" size="size" default="default"/}}
Where:
Parameter | Optional | Value |
---|---|---|
No | Email value, e.g. [email protected] | |
size | Yes | From 1px to 512 px, e.g. "50" |
default | Yes | Image 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
Result
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}}
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}}