• 916VT

    (@vincent916)


    Hi there,

    I can’t change my default avatar image. I found this code and a lot of quite similare versions that I’ve tried :

    add_filter( 'avatar_defaults', 'newgravatar' );
    function newgravatar ($avatar_defaults) {
        $myavatar = get_bloginfo('template_directory') . '/images/own-gravatar.jpg';
        $avatar_defaults[$myavatar] = "Own";
        return $avatar_defaults;
    }

    But on the backoffice discussion page and on the comment area, the image is not displayed. The return src url is :

    https://1.gravatar.com/avatar/3923c5b0606e373cb28b02f249064f2f?s=80&d=http%3A%2F%2F((mysite))%2Fwp-content%2Fthemes%2Frttw_v2%2Fimg%2Favatar.jpg%3Fs%3D80&r=G

    I don’t know where the first part is coming from. It looks to work for thousand of WP users…

    Anyone has an idea to fix ?

    Thanks a lot for your help !

Viewing 15 replies - 1 through 15 (of 29 total)
  • Try the following:

    add_filter( 'pre_option_avatar_default', function( $value ) {
    	return 'https://path/to/default.png';
    } );
    Thread Starter 916VT

    (@vincent916)

    Hi Konstantion,
    Unfortunately, the issue stays exactly the same…

    Thread Starter 916VT

    (@vincent916)

    Actually, the return url is not exactly the same…

    https://1.gravatar.com/avatar/1d2ab164559aaf8a30eebf516d2f63ad?s=80&d=http%3A%2F%2F((mysite))%2Fwp-content%2Fthemes%2Frttw_v2%2Fimg%2Favatar.jpg%3Fs%3D80&r=G

    Looks like your theme is overwriting it. Does it also not work on a different theme?

    Thread Starter 916VT

    (@vincent916)

    So, I tried on Twenty Fifteen but it did not work neither.

    Thread Starter 916VT

    (@vincent916)

    Do you know where may I check for the overwriting ? Right now, I just call

    <?php echo get_avatar( $comment, 80 ); ?>

    On my functions.php file to get a custom template based on wp_list_comments().

    Could be in a theme or plugin. I tested the code on my local install and it worked. Where are you inserting it?

    Thread Starter 916VT

    (@vincent916)

    I have tried at the top and at bottom on function.php of my custom theme and Twenty Fifteen.

    I will try to turn off all plugins and I let you know.

    Thread Starter 916VT

    (@vincent916)

    Ok, so I have tried without plugins on a local and live intalls but both did not work.

    I still got the new avatar name displayed on admin page “Discussion” and I can select it but the image link is still wrong.

    Don’t look into the Discussion settings, create an anonymous comment and look at the gravatar there.

    Thread Starter 916VT

    (@vincent916)

    I made one, but the url is still broken.
    The error looks the same, with the gravatar url still showing up somehow.

    Can you show me the code you pasted in full, as well as the gravatar link generated in the anonymous comment?

    Thread Starter 916VT

    (@vincent916)

    Sure.

    Here is the code :

    add_filter( 'avatar_defaults', 'newgravatar' );
    function newgravatar ($avatar_defaults) {
        $myavatar = get_bloginfo('template_directory') . '/img/avatar.png';
        $avatar_defaults[$myavatar] = "Own";
        return $avatar_defaults;
    }

    And the url for anonymous comment :

    <img height="80" width="80" class="avatar avatar-80 photo avatar-default" src="https://0.gravatar.com/avatar/?d=https://localhost:8888/mysite/wp-content/themes/rttw_v2/img/avatar.png&s=80" alt="">

    You ignored the code snippet I gave you above with the pre_option_ filter.

    Thread Starter 916VT

    (@vincent916)

    Oh yes sorry, it was here but just below :

    add_filter( 'avatar_defaults', 'newgravatar' );
    function newgravatar ($avatar_defaults) {
        $myavatar = get_bloginfo('template_directory') . '/img/avatar.png';
        $avatar_defaults[$myavatar] = "Own";
        return $avatar_defaults;
    }
    
    add_filter( 'pre_option_avatar_default', function( $value ) {
    	return 'https://localhost:8888/mysite/wp-content/themes/rttw_v2/img/avatar.png';
    } );
Viewing 15 replies - 1 through 15 (of 29 total)
  • The topic ‘Issue for changing Mystery Man avatar’ is closed to new replies.