Showing Avatars

Sherry Collins asked on June 29, 2015 18:20

I have a sidebar on one of my Blog pages. One of the sections of the side bar is latest comments where we are showing the latest 5 comments for all the Blogs. One of the requirements is to show the Avatar of the person making the comment. I used this transformation:

<a href="<%# GetUserProfileURL(CurrentUser.UserName) %>"><img src="<%# GetUserAvatarImageUrl(CurrentUser.UserAvatarID, CurrentUser.UserID, 20, 20, 20) %>"

This does not work quite right because it returns the Avatar of the current user, not the necessarily the user to made the comment. What I need is for it to evaluate the CommentUserName so that it gets the correct Avatar for whoever posted the comment.

For example. I am the current user and I make a comment, but the next 4 comments were created by someone else. My Avatar should appear next to the top comment and the other 4 comments should have the avatars of whoever created them.

Any help would be appreciated.


Recent Answers

Bryan Soltis answered on June 30, 2015 15:27

You can use the Blogs Comments Viewer webpart. In your transformation for the blog comments, you need to make sure you are pull the CommentUserName field for the image.

<%# GetUserAvatarImage(50, HTMLEncode(GetNotEmpty("CommentUserName"))) %>

You can find some more Avatar functions here:

  • Bryan
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.