Avatars configured for comments

A minor but quick change: I've included the ability for comments to show an avatar. Essentially sign up at gravatar.com, upload an image that "represents" you, and it'll then appear here if you comment.

For the Graffiti freaks out there, here's the line of code in my comments.view file (this is a file loaded by my post.view file that displays all the comments, plus the add-a-comment form):

$macros.gravatar($comment.Email, $comment.Username, $comment.IPAddress, "%{size ='60'}")

Enjoy.

Album cover for When It Falls Now playing:
Zero 7 - Passing By (Album Version)
(from When It Falls)


Loading similar posts...   Loading links to posts on similar topics...

4 Responses

 avatar
#1 Terri Morton said...
29-Dec-08 8:00 PM

FWIW, I had picked up somewhere that it's a good idea to test for the presence of an IP address, so I use a variation of the above:

#if($comment.IPAddress)
<span class=&quot;avatar&quot;>
  $macros.gravatar($comment.Email, $comment.Username, $comment.IPAddress, &quot;%{size ='60'}&quot;)
</span>
#end
julian m bucknall avatar
#2 julian m bucknall said...
29-Dec-08 10:26 PM

Terri, I had a quick look through the Graffiti.Code code to $macros.Gravatar using Reflector. It seems that if the IP address is null (but not empty), a method (Identiicon.Code()) gets called that will throw an exception. That's the only reason I can see for checking for an IP address.

Cheers, Julian

 avatar
#3 Terri Morton said...
30-Dec-08 9:11 AM

I found the source of that code, in FriendFeed. Someone had imported comments from dasBlog, and those do not include IP addresses. So I adopted his approach to be safe. friendfeed.com/.../Has-anyone-setu

julian m bucknall avatar
#4 julian m bucknall said...
30-Dec-08 10:54 AM

Magic, Terri. Thanks for the explanation and the link.

Cheers, Julian

Leave a response

Note: some MarkDown is allowed, but HTML is not. Expand to show what's available.

  •  Emphasize with italics: surround word with underscores _emphasis_
  •  Emphasize strongly: surround word with double-asterisks **strong**
  •  Link: surround text with square brackets, url with parentheses [text](url)
  •  Inline code: surround text with backticks `IEnumerable`
  •  Unordered list: start each line with an asterisk, space * an item
  •  Ordered list: start each line with a digit, period, space 1. an item
  •  Insert code block: start each line with four spaces
  •  Insert blockquote: start each line with right-angle-bracket, space > Now is the time...
Preview of response