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've searched google quite a bit and every site has the same filter but it doesn't seem to be working for me. Not sure if it's my setup or just old code.

I'm trying this:

add_filter( 'avatar_defaults', 'newgravatar' );  

function newgravatar ($avatar_defaults) {
    $myavatar = get_bloginfo('template_directory') . '/img/blog_noPhoto.jpg';
    $avatar_defaults[$myavatar] = "Default Avatar";
    return $avatar_defaults;
}

However, when I look at my template code it's adding http://0.gravatar.com/avatar/?d= before the full URL of the image. I am using the "User Avatar" plugin but it seemed to be the same if I disabled that.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I figured this out. The server I am working on doesn't have access to the outside. So, even though the image is in my template folder, the gravatar.com call in front of the image path was causing the error.

share|improve this answer

It is giving you that error because the image doesn't exist. I would try changing it to:

add_filter( 'avatar_defaults', 'newgravatar' );  

function newgravatar ($avatar_defaults) {
    $myavatar = site_url() . '/img/blog_noPhoto.jpg';
    $avatar_defaults[$myavatar] = "Default Avatar";
    return $avatar_defaults;
}

So the link to the image file would actually be, http://www.example.com/img/blog_noPhoto.jpg

share|improve this answer

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.