Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.


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!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
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. –  toscho Oct 9 '12 at 18:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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