Generating Gravatar Image Request URLs
Gravatar is a service that allows users to centrally manage their avatar across several websites. Slate makes use of Gravatar in several places, such as the "Dashboard" tab on a person record. It's possible to retrieve a user's Gravatar (e.g., to display in a portal, to merge into a mailing) by passing in a hash of their email address into an image request, which Gravatar outlines here.
Generating the Email Hash
- Add a subquery export.
- Specify a name, like "email-hash".
- Set the output setting to "Formula".
- Add an export for the email address.
- Use the following formula, replacing "@Email" with the export's name you added in the above step:
lower(convert(varchar(32), hashbytes('MD5', lower(@Email)), 2))
- Click save.
|
 |
Performing the Image Request
We can now use the hashed email address above to perform the image request.
- Add an image.
- Set the URL setting to the following URL, replacing "{{email-hash}}" with the name you used in your subquery export:
https://www.gravatar.com/avatar/{{email-hash}}
- If you want to instruct Gravatar to return something if a Gravatar is not found for the hashed email address, you can modify the URL using the d parameter. The below example returns "mystery-person", or gray avatar:
https://www.gravatar.com/avatar/{{email-hash}}?d=mp
- If you want to control the size of the Gravatar, you can modify the URL using the s parameter. The proceeding example builds on the last and sizes the Gravatar to 45px by 45px:
https://www.gravatar.com/avatar/{{email-hash}}?d=mp&s=45
- Click save.
|