1

I am using the follow function to create a custom default avatar for users who comment and do not have a gravatar setup.

 if(!function_exists('custom_avatar')){
    function custom_avatar($avatar_defaults){
        $new_default_icon = get_bloginfo('template_directory') . '/images/VR-default-avatar.png';
        $avatar_defaults[$new_default_icon] = 'VR Custom Avatar';
        return $avatar_defaults;
    }
    add_filter('avatar_defaults','custom_avatar');
 }

and when I go to the admin panel under settings --> discussion it shows the new line with the text VR custom avatar, but the link to the image is broken. Also when I select and save and then go to the blog the default image is also a broken image. I went to google chrome and did an inspection on the broken image and it shows:

<img alt="" src="http://0.gravatar.com/avatar/25c562d0eebef3b375ae2d0fea8ad716?s=32&amp;d=http%3A%2F%2Fwww.violet-rain.com%2Fwp-content%2Fthemes%2Fartificer%2Fimages%2FVR-default-avatar.png%3Fs%3D32&amp;r=G&amp;forcedefault=1" class="avatar avatar-32 photo" height="32" width="32">

What am I doing wrong that it is pulling from the gravatar website?

0

This http://www.violet-rain.com/wp-content/themes/artificer/images/VR-default-avatar.png produces 404. You probably meant artificer-child (working link) which would be in stylesheet (child theme) directory, not template (parent theme) directory.

  • traded out get_bloginfo('template_directory') for get_stylesheet_directory_uri() and it worked like a charm. Thank you. – tech May 25 '14 at 19:49
  • So if you use a custom avatar which results in a 404 link, WordPress tries to load one from gravatar.com? I only ask because I have a site behind a htaccess password at the moment and the custom gravatar is not loading, even though I've triple checked the URL (and tried get_stylesheet_directory_uri() and get_template_directory_uri() ) – patrickzdb Aug 12 '14 at 15:34
0

Why don't just use get_avatar()?

get_avatar(
    $comment,
    50,
    get_template_directory_uri() . '/images/VR-default-avatar.png'
);

Though it won't create any addition user choosable avatar in settings, but will do the trick.

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.