I am using bbPress on my site and have (bbPress) Login Widget on my sidebar. Is there a way to change the default image size from 40 to 80 or other number? here is the code from the core files:

<?php echo get_avatar( bbp_get_current_user_id(), '40' ); ?>

How do I change that default 40 px without editing the core files?
Can i filter it somehow?

Thanks in advance, you are my last hope to find answer to this problem of mine!


You can filter 'get_avatar':

add_filter( 'get_avatar', 'wpse_67657_new_avatar', 10, 5 );

function wpse_67657_new_avatar( $avatar, $id_or_email, $size, $default, $alt )
    // create a new img element or …
    $new = str_replace( 's=40', 's=80', $avatar );
    $new = str_replace( 'avatar-40', 'avatar-80', $new );
    $new = str_replace( " height='40' width='40'", " height='80' width='80'", $new );
    return $new;

Filtering the size only is currently not possible.

  • well if i want to change the size to 80 how should this function look like? – Radi Oct 9 '12 at 18:47
  • @Radi I have included an example now. It is not tested, more a general idea. – fuxia Oct 9 '12 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.