Rob Ferrer’s Thoughts and Writings

I thought it was about time I started a blog!
  • rss
  • Home
  • About
  • Gallery

Freshy 2 & Gravatar Bugfix

June 16, 2008

Please Note: [update 2008-08-20]: This has now been fixed as of Freshy 2.0.8, so you shouldn’t need to make any changes other than updating to the latest version. I am leaving this post for the sake of archive.

Any regular readers (although I don’t think I actually have any!) of this blog will notice I recently changed the theme to the fantastic Freshy 2 theme from Jide.fr. Together with the customise plugin it’s a great theme with many great features, including support for the Gravatar plugin.

Unfortunately as of version 2.0.6 there’s a very small error in the way the Gravatar function is implemented, which means the Gravatars aren’t displayed properly (and in fact it means commenter’s email addresses are displayed in the source).

Luckily the fix is very simple. You need to edit the file comments.php (using the theme editor or your favourite method), and find the following section (around line 37)(sorry about the indentation - Wordpress insists on removing it!):

<?php // gravatars
if (function_exists('gravatar')) {
if ('' == $comment->comment_type) {
echo '<img class="avatar" src="';
gravatar($comment->comment_author_email);
echo ‘” alt=”‘.$comment->comment_author.’” width=”40″ height=”40″ />’;
} elseif ( (’trackback’ == $comment->comment_type) || (’pingback’ == $comment->comment_type) ) {
echo ‘<img class=”avatar” src=”‘;
gravatar($comment->comment_author_url);
echo ‘” alt=”‘.$comment->comment_author.’” width=”40″ height=”40″ />’;
}
} else {
//echo ‘<img class=”avatar” src=”‘.get_bloginfo(’stylesheet_directory’).’/images/default_avatar.png” alt=”‘.$comment->comment_author.’” width=”40″ height=”40″ />’;
}
?>

And you need to change the two gravatar() function calls to look like this (remove the paramters):

gravatar();

If you prefer you can download a fixed comments.php to replace you existing one here:

coments.php.zip

These changes actually make a lot of the code redundant, as it’s not possible to display a Gravatar for a trackback (there is no email address)

Make the above changes and you should be able to see Gravatars for all your visitors!

I also note, it looks that as of Wordpress v2.5, that gravatar support is built in. Note, if you use this the get_avatar() function does require the email address of the user as a parameter!

Update: Please note, the above download is for the old Frshy 2.06. Freshy 2.07 may have a different comments.php file, although it still has the bug so you will need to make the repair manually (let me know if you have any questions)!

Update 2: The bug is now fixed as of version 2.0.8

Comments
5 Comments »
Categories
Uncategorized
Tags
Freshy 2, gravatar, wordpress, WordPress 2.5
Comments rss Comments rss
Trackback Trackback

Pages

  • About
  • Gallery

Links

  • My LinkedIn Profile
  • Yuwie - social networking
  • Zopa: £30 free

Tags

car insurance cashback Churchill clipboard copy Direct Line easter flash gadgets Gallery google Homepages Friends insurance junk mail kayaking Lost mobile MySearchFunds openid outdoors show paste photography Photolate phpmyopenid Privilege rant review rodeo search security snow spam t-mobile Theme the mobile outlet TV web Weebls Stuff welcome Wii wordpress WordPress 2.5 WPG2 Yahoo yuwie

Recent Photos

DSC_0226
DSC_0221
DSC_0217
DSC_0210

Meta

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox