• I tried this is functions.php `
    add_filter( ‘avatar_defaults’, ‘new_default_avatar’ );

    function new_default_avatar ( $avatar_defaults ) {
    //Set the URL where the image file for your avatar is located
    $new_avatar_url = get_bloginfo( ‘template_directory’ ) . ‘/images/avatar.png’;
    //Set the text that will appear to the right of your avatar in Settings>>Discussion
    $avatar_defaults[$new_avatar_url] = ‘Your New Default Avatar’;
    return $avatar_defaults;
    }`

    And in my comments.php I have `<?php
    if (function_exists(‘get_avatar’)) {
    echo get_avatar($comment, $size = ’56’);
    }
    ?>`

    But the custom avatar will not show. What I get instead is an image placeholder with the link https://1.gravatar.com/avatar/d34b49e186db2b0bc1016f9fc0004195?s=56&d=http%3A%2F%2F192.168.1.100%2Fwp-content%2Fthemes%2Fhannawerner.com_2%2Fimages%2Favatar.png%3Fs%3D56&r=G

    Does anyone know what I’m doing wrong?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    It appears that to have echo get_avatar(); display a fixed avatar image option you added to the discussion settings and selected, you must pass FALSE instead of $comment. Any time you provide an ID or email or comment object, the request gets routed to gravatar.com, regardless of the option selected. Go figure.

    Thread Starter Sinopa

    (@sinopa)

    You could you please tell me how that would work in the real world? ??

    Moderator bcworkz

    (@bcworkz)

    ?? Try changing your get_avatar() call to this:
    echo get_avatar(FALSE, $size = '56');

    Now when you select ‘Your New Default Avatar’ in settings, avatar.png will be used for all avatars.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Gravatar not working.’ is closed to new replies.