Search code examples
wordpressgravatar

How do I add another avatar to the wordpress default ones?


I want to put some good avatar instead of the wordpress default. How can i do this without touching the core.


Solution

  • It's very easy, you don't have touch the core. Just use the avatar_defaults filter.

    There is post on that here

    /**
    * add a default-gravatar to options
    */
    if ( !function_exists('fb_addgravatar') ) {
    function fb_addgravatar( $avatar_defaults ) {
    $myavatar = get_bloginfo('template_directory') . '/images/avatar.gif';
    $avatar_defaults[$myavatar] = 'people';
    
    $myavatar2 = get_bloginfo('template_directory') . '/images/myavatar.png';
    $avatar_defaults[$myavatar2] = 'wpengineer.com';
    
    return $avatar_defaults;
    }
    
    add_filter( 'avatar_defaults', 'fb_addgravatar' );
    }