Blog Comments Now Display Sueetie Member Profile Avatars

I started working on something else in Sueetie this fine Sunday morning when observing the lack of integrated BlogEngine.NET Avatars bugged me enough to get it out of the way.  YetAnotherForum.NET avatars are integrated into the Sueetie framework, so BlogEngine.NET avatar integration remained to complete the job.

Rather than retrieve a commenter avatar from MonsterID, Wavatar or Identicon on Sueetie blogs, the comment photo now displays the member profile avatar.  They are also linked back to the user profile page.

 

Since we were already using a custom BlogEngine.NET CommentViewBase class to support Sueetie Following and Favorites, I simply updated it’s Gravatar() method. "0t.jpg" is the default avatar thumbnail filename in Sueetie.  0t.jpg is also returned from the provider if the member has no avatar, so not much code was required to do the job.  It would have been nice to retrieve avatar information from an enhanced SueetieBlogComment object rather than make a trip to the database. This was my approach with YetAnotherForum.NET avatar integration, but given the fact that blog comments originate from XML, we’ll live with a visit to the database for now.

protected string Gravatar(int size)
{
    if (BlogSettings.Instance.Avatar == "none")
        return null;

    string thumbnail = "<img class=\"BlogAvatar\" src=\"/images/avatars/0t.jpg\" alt=\"\" />";

    if (String.IsNullOrEmpty(Comment.Email) || !Comment.Email.Contains("@"))
    {
        return thumbnail;
    }
    else
    {
        SueetieUser sueetieUser = SueetieUsers.GetSueetieUserByEmail(Comment.Email);

        if (sueetieUser.Email != null)
        {
            thumbnail = string.Format("<a href=\"/members/profile.aspx?u={0}\"
                class=\"BlogAvatarLink\"><img class=\"BlogAvatar\"
                src=\"/images/avatars/{1}\" alt=\"{2}\" /></a>",
                sueetieUser.UserID, sueetieUser.AvatarThumbnailFilename, 
                sueetieUser.DisplayName);
        }
        return thumbnail;
    }

}

The display of member avatars in blog comments completes the integration of User Avatars across Sueetie content.  We’ll look at integrating member avatars into Sueetie wiki and media gallery content as well. The wiki will get more love after ScrewTurn Wiki 3.x is released.  I plan on spending more quality time with the media gallery after I upgrade to the new 2.3 release of Gallery Server Pro.  For now, BlogEngine.NET Avatar integration is today’s fun Sueetie Factoid, and as Forrest says, "one less thing."

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.