Who is Ali Özgür?

RecentComments

Comment RSS

BlogEngine .NET 1.3 uses www.gravatar.com/avatar.php?gravatar_id=[MD5 Hash] to retreive Gravatar images for the comments. But this url is not supported by Gravatar anymore as far as I understand. We have to replace this url with this one http://en.gravatar.com/avatar/.

In order correct this url open CommentView.ascx.cs file found in "User controls" folder and replace the source code of the Gravatar method with this one

001  protected string Gravatar(string email, string name, int size)
002
003  {
004
005    if (email.Contains("://"))
006
007      return
008
009          string.Format(
010
011              "<img class=\"thumb\" src=\"http://images.websnapr.com/?url={0}&amp;size=t\" alt=\"{1}\" />", name,
012
013              email);
014
015    //http://www.artviper.net/screenshots/screener.php?&url={0}&h={1}&w={1}
016
017    MD5 md5 = new MD5CryptoServiceProvider();
018
019    byte[] result = md5.ComputeHash(Encoding.ASCII.GetBytes(email));
020
021
022
023    StringBuilder hash = new StringBuilder();
024
025    for (int i = 0; i < result.Length; i++)
026
027      hash.Append(result[i].ToString("x2"));
028
029
030
031    StringBuilder image = new StringBuilder();
032
033    image.Append("<img src=\"");
034
035        
036
037    //Change the url
038
039    image.Append("http://en.gravatar.com/avatar/");
040
041        
042
043    //Change the MD5 hash appending code
044
045    image.Append(hash.ToString());
046
047    
048
049    image.Append("&amp;rating=G");
050
051    image.Append("&amp;size=" + size);
052
053    image.Append("&amp;default=");
054
055    image.Append(Server.UrlEncode(Utils.AbsoluteWebRoot + "themes/" + BlogSettings.Instance.Theme + "/noavatar.jpg"));
056
057    image.Append("\" alt=\"\" />");
058
059    return image.ToString();
060
061  }

After changing the url in source code you do not nedd to build/recompile BE you simply replace the old file with the modified one. 


Posted in: BlogEngine.NET  Tags:
Comments are closed