Freshy 2 & Gravatar Bugfix


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


5 responses to “Freshy 2 & Gravatar Bugfix”

  1. Thanks for fix,
    can you also fix problems with visibility of sidebars in IE6
    this site and my test site for Freshy do not show them, but Fox and Opera do.

    thanks

  2. Here is this site from my IE6
    [link broken]

    I was happy when I found this theme and customize plugin, wanted to teach my students easiest way of learning WP, hmmmm it is very strange my friend can see your sidebar from his iE6, I can see developer sidebar, but mine site and yours not, maybe there is some plugin conflict.
    Well 20% of visitors still use IE6. Maybe to upgrade to iE7 and just forget all 🙂

    regards

  3. @Drag: Strange. It works ok on mine, and on browsershots.

    I get 10% using IE6.

    I have to admit I don’t have the time to take the style apart to fix this, the Gravatar bug was just a simple fix (and a privacy issue!)

    Good luck!!

Leave a Reply

Your email address will not be published. Required fields are marked *