Skip to content

Commit

Permalink
Default avatars for those with email addresses but no gravatar.
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkie committed Mar 24, 2011
1 parent e12c0a8 commit 0c75c47
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion models/author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ def avatar_url
"/images/avatar.png"
else
# Using gravatar
"http://gravatar.com/avatar/" + Digest::MD5.hexdigest(email) + "?s=48"
current_url = "http://gravatar.com/avatar/" + Digest::MD5.hexdigest(email) + "?s=48&r=r&d=404"
res = Net::HTTP.get_response(URI.parse(current_url))
if res.class == Net::HTTPNotFound
"/images/avatar.png"
else
current_url
end
end
else
# Use the twitter image
Expand Down

0 comments on commit 0c75c47

Please sign in to comment.