A

Change gravatar size in bbPress theme

Here is a quick post on how you can change the size of the gravatar size on your bbPress forums within your theme and not touching any of its core files. By default the gravatar is of size 48px (image of 48 X 48) and here we are going to change it to something big, […]

Here is a quick post on how you can change the size of the gravatar size on your bbPress forums within your theme and not touching any of its core files.

By default the gravatar is of size 48px (image of 48 X 48) and here we are going to change it to something big, lets say a 100px gravatar (image of 100 X 100).

In your theme, open post.php for editing and if its not there, then copy post.php from the default theme to your theme folder and proceed.

In bbPress 1.0+ you will find the function post_author_avatar_link();

and in previous versions, you will find the function post_author_avatar();

Now change it to post_author_avatar_link($size='100');

or post_author_avatar($size='100'); as your case may be.

Save the file and see the changes. Now replace 100 with any size of your liking. The max size of a gravatar is 512px.

Similarly if you want to chnage the gravatar size on the Profile page, then change

<?php if ( $avatar = bb_get_avatar( $user->ID) ) : ?>

to

<?php if ( $avatar = bb_get_avatar( $user->ID,$size='150' ) ) : ?>

I am working heavily on WordPress and bbPress theme development these days, so make sure you subscribe to my feeds or email updates if you don’t want to miss such tips especially for bbPress which is pretty new on the rack and lacks proper documentation (doesn’t even have a codex yet, at the time of writing this post). So, it will be a good idea to subscribe. Isn’t it? Have your say in the comments.

3 responses to “Change gravatar size in bbPress theme”

  1. College Girl says:

    Do you know how you can add a default gravatar option? So if the user doesn’t have one, it will display one from your server?

    • Ashfame says:

      I have actually done that on my blog here only. Ping me to remind incase I forget to tell you.

    • Ashfame says:

      Yes! Find your code of comments and edit the line get_avatar to make it look like this

      <?php echo get_avatar($comment,$size='50',$default='path-to/gravatar.jpg' ); ?>