Pragmatic Developer

Ali Özgür

Bookmark Blog

Add to Technorati Favorites

Google Talk

Chat with Ali Özgür

Purchase PragmaSQL from

Calendar

«  August 2008  »
MoTuWeThFrSaSu
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567
View posts in large calendar

Tag Cloud

Don't show

    Authors

    Recent Comments

    Banners




    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    if (email.Contains("://"))
    004      return
    005          string.Format(
    006              "<img class=\"thumb\" src=\"http://images.websnapr.com/?url={0}&amp;size=t\" alt=\"{1}\" />", name,
    007              email);
    008    //http://www.artviper.net/screenshots/screener.php?&url={0}&h={1}&w={1}
    009    MD5 md5 = new MD5CryptoServiceProvider();
    010    byte[] result = md5.ComputeHash(Encoding.ASCII.GetBytes(email));
    011
    012    StringBuilder hash = new StringBuilder();
    013    for (int i = 0; i < result.Length; i++)
    014      hash.Append(result[i].ToString("x2"));
    015
    016    StringBuilder image = new StringBuilder();
    017    image.Append("<img src=\"");
    018        
    019    //Change the url
    020    image.Append("http://en.gravatar.com/avatar/");
    021        
    022    //Change the MD5 hash appending code
    023    image.Append(hash.ToString());
    024    
    025    image.Append("&amp;rating=G");
    026    image.Append("&amp;size=" + size);
    027    image.Append("&amp;default=");
    028    image.Append(Server.UrlEncode(Utils.AbsoluteWebRoot + "themes/" + BlogSettings.Instance.Theme + "/noavatar.jpg"));
    029    image.Append("\" alt=\"\" />");
    030    return image.ToString();
    031  }

    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:

    Currently rated 5.0 by 1 people

    • Currently 5/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5
    Comments are closed