• Hello,

    The radio button and description displays but the image doesn’t. I am using this code in functions.php, after <?php and before
    <?php }
    // end function

    if ( !function_exists(‘fb_addgravatar’) ) {
    function fb_addgravatar( $avatar_defaults ) {
    $myavatar = get_bloginfo(‘template_directory’).’/public_html/wp-content/themes/platformbase/images/avatar.png’;
    //default avatar
    $avatar_defaults[$myavatar] = ‘AceDoubleYou’;
    return $avatar_defaults;
    }
    add_filter( ‘avatar_defaults’, ‘fb_addgravatar’ );
    }

Viewing 15 replies - 1 through 15 (of 19 total)
  • I dont think you need to put /public_html/ into the URL

    Thread Starter missyjknox

    (@missyjknox)

    I removed /public_html and the image still does not appear.

    If you’re using get_bloginfo(‘template_directory’) function then your code will look like this:
    $myavatar = get_bloginfo('template_directory').'/images/avatar.png';

    get_bloginfo(‘template_directory’) outputs full URL to active theme.

    Then do you know that right link which it should be?

    try what Ctrl-C mentioned first.

    Thread Starter missyjknox

    (@missyjknox)

    Hey Ctrl_C:

    Originally, I uploaded the image to my Media Library and placed the URL within the code like this and it did not work:

    add_filter( ‘avatar_defaults’, ‘newgravatar’ );
    function newgravatar ($avatar_defaults) {
    $myavatar = get_bloginfo(‘template_directory’).’/images/avatar.png’;
    $avatar_defaults[$myavatar] = “AceDoubleYou”;
    return $avatar_defaults;
    }

    Then I thought to upload the image to my CPanel and place it in the images file of the theme and use this code, again it did not work:

    add_filter( ‘avatar_defaults’, ‘newgravatar’ );
    function newgravatar ($avatar_defaults) {
    $myavatar = get_bloginfo(‘template_directory’).’https://acedoubleyou.com/wp-content/uploads/2011/08/Favicon2.ico&#8217;;
    $avatar_defaults[$myavatar] = “AceDoubleYou”;
    return $avatar_defaults;
    }

    With that said, I don’t understand your comment above. Do I use the path where I stored the file in the images folder or do I use the URL where it’s stored in Media Library? Considering I did both, are there any other suggestions?

    I want to know the purpose why you did this filter here.

    Do you want to Local(cache) the avatar images yourself in your host. or do you just want to change the Dir? just like the blog post below->

    then i think you can make it by following that post.

    Thread Starter missyjknox

    (@missyjknox)

    @hzlzh I followed the instructions included in the link you posted (i think the code I provided in my post above is evident of that) and the image is not showing. I do not know exactly what you are asking me to tell you.

    @missyjknox:
    That’s weird. I can achieve that by follow that tutorial and put those code into my function.php.

    Thread Starter missyjknox

    (@missyjknox)

    It’s only the image that’s not showing, and I am not the first that this has happened to. This post has the same issue, but there was no resolution…

    Thread Starter missyjknox

    (@missyjknox)

    Did you try this? (I paste it from the post i mentioned.)

    2. Then paste the following code in there
    
    add_filter( 'avatar_defaults', 'newgravatar' );
    
    function newgravatar ($avatar_defaults) {
    $myavatar = get_bloginfo('template_directory') . '/images/gravataricon.gif';
    $avatar_defaults[$myavatar] = "WPBeginner";
    return $avatar_defaults;
    }
    
    You need to understand the variables in the code above.
    
    ‘/images/gravataricon.gif’ is the location of the image file. It must be saved under the theme folder that you are using.
    
    Change WPBeginner to the name that you want to give your Gravatar and you should be all set.
    Thread Starter missyjknox

    (@missyjknox)

    I will try this next. My question is, should the image be placed in the image folder of the theme or can I use the url provided with the image uploaded to WP media library? Please keep in mind the process is working, but the image is not showing, so it is crucial that I understand exactly where the code expects the image to be.

    Yes, I used to change the default avatar image into a Game icon and i mad it.

    also I think you can put the image in any DIR you want, both your theme dir or your WP root dir, that’s ok, just set the right URL in the function.

    I just did like this

    Thread Starter missyjknox

    (@missyjknox)

    Here is the code used and placed now at the end of functions.php. Same result, no image:

    add_filter( ‘avatar_defaults’, ‘newgravatar’ );

    function newgravatar ($avatar_defaults) {
    $myavatar = get_bloginfo(‘template_directory’) . ‘/images/avatar.png’;
    $avatar_defaults[$myavatar] = “AceDoubleYou”;
    return $avatar_defaults;
    }

    Thread Starter missyjknox

    (@missyjknox)

    I am not an expert at code, but I get the impression this code can’t locate the image, and I can assure you the image is in the images folder.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Custom Default Avatar Image Not Showing’ is closed to new replies.