Skip to content

Instantly share code, notes, and snippets.

@perliedman
Created November 5, 2015 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perliedman/e4590554c33849fcc424 to your computer and use it in GitHub Desktop.
Save perliedman/e4590554c33849fcc424 to your computer and use it in GitHub Desktop.
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