Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gravatar UrlHelper
public static class GravatarUrlHelper
{
public static string GravatarUrl(this UrlHelper urlHelper, string emailAddress, int size = 38, string defaultAvatar = "identicon")
{
var md5 = MD5.Create();
var hash = md5.ComputeHash(Encoding.ASCII.GetBytes(emailAddress.Trim().ToLowerInvariant()));
return string.Format("https://www.gravatar.com/avatar/{0}?s={1}&d={2}", hash, size, defaultAvatar);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment