Help With Displaying Avatar of Commenter

Hi there,

I presume this line of code in the comment loop inserts the avatar of user id ‘1’ next to every comment, whether or not it was posted by user ‘1’?

<?php echo get_avatar(1,'32','identicon'); ?>

How should this be modified to retrieve the ID (and avatar) of the user actually posting the comment?

i.e. in the spirit of:

<?php echo get_blog_avatar($wpdb->blogid,'128','identicon'); ?>

Thanks!

  • Andrew
    • Champion of Loops

    Hiya,

    There’s a plugin included in the avatars download that helps you with this: avatar-comments.php

    Just toss it into mu-plugins.php

    If you look at the top of that file you’ll see a usage example. Just toss it into your themes in the comment loop.

    Note that all of the themes in our latest theme pack should already have this added.

    Thanks,

    Andrew

  • mgravel
    • New Recruit

    Thanks, Andrew.

    That’s helpful but I suspect I have more tweaking to do on my theme.

    I have avatar-comments.php in the mu-plugins folder and I inserted

    <?php avatar_display_comments(get_comment_author_email(),'48',''); ?>

    in the comment loop, but no luck.

    But I’m using the thesis theme with openhook so perhaps that’s a problem. I’ll keep at it and report back.

    Thanks.

  • mgravel
    • New Recruit

    Ok. I think I got it.

    Instead of:

    <?php avatar_display_comments(get_comment_author_email(),'48',''); ?>

    which is the usage example lifted from avatar-comments.php,

    I inserted:

    <?php echo get_avatar(get_comment_author_email(),'48',''); ?>

    which appears to work like a charm.

    But I would love to know the difference and the reason why the code sample in avatar-comments.php didn’t work for me.

    Just concerned about doing the right thing!

    Thanks.