Hello all,
This evening I have decided to create a nice quick package to help use Gravatar easily on your umbraco blog/site. There have been snippets on other blogs to help you achieve this, I have just created two XSLT Extensions to use in your XSLT and an example XSLT file to show how you can use the helpers.
If you haven't heard of Gravatar before, it is a service that allows you to upload an image so you can have a globally recgonised avatar on the web that is associated to your email address. The most useful scenario is on your Umbraco blog to display Gravatar images of visitors who have left comments, but you may think of some other creative scenarios you may want to use it in.
This is my Gravatar
The two methods available are
getGravatarImageURL and FormatStringToMD5
The first method getGravatarImageURL expects two parameters, which are below.
stringForGravatar: the email address that you want the Gravatar image for.
defaultImage: this is an absolute URL to a default image if the Gravatar image does not exist.
This Returns: a full absolute URL to an the Gravatar image.
The second method FormatStringToMD5 expects one parameter, which is below.
stringToFormat: this is the string you wish to format as a MD5 hash.
This Returns: an MD5 hashed string, which you can use manually to build up the Gravatar URL if you prefer, of for MD5 hashing other strings.
This package installs the following files:
- bin/CWSHelperGravatar.dll
- xslt/CWS_Example_DisplayYourGravatar.xslt
- /usercontrols/Installer/CWSGravatar/cwsGravatarInstaller.ascx
The installer usercontrol cwsGravatarInstaller.ascx is used to modify the /config/xsltExtensions.config
to setup my custom XSLT extension to allow us to do the MD5 hashe & create the full Gravatar URL.
The actual package installs the following into umbraco:
- Macro: [XSLT] CWS:Display Your Gravatar Example
- XSLT: CWS_Example_DisplayYourGravatar.xslt
To use this package just install this package, to do this take the following steps.
- Login to umbraco
- Goto the Developer section
- Right click the Macros node
- Select Import Package
- Press Browse and find the zip package file you have downloaded
- Follow the steps in the wizard
- Once installed insert the macro into your XHTML template
- Insert your email address and the Absolute URL to an image you want to use for a default image.
So enough with the ranting, here is the link to the file your after......
Download Creative Website Specialist - Gravatar Package v1.0.0
I look forward to any feedback or comments and credit goes to Per Ploug Hansen as his original code has been used for the FormatStringToMD5 method.