0

I have this code that pulls a user's gravatar:

if( $current_user->ID == 0 ) {
    // Not logged in.
    echo '<p><img src="'.get_stylesheet_directory_uri().'/img/wpb-default-gravatar.png" alt="תמונת פרופיל"></p>';
    echo '<p>רוצה למכור?</p>';
    echo '<p><a href="חשבון-חנות">פתח חנות</a></p>';
}
else {
    $current_user = wp_get_current_user();
    $args = array(
        'height'    => 50,
        'width'     => 50,
        'class'     => 'gravatar',
        'scheme'    => 'https'
    );
    echo '<p>'.get_avatar( $current_user->ID, 50, '', 'תמונת פרופיל', $args ).'</p>';
    echo '<p>היי, ' . $current_user->user_firstname.'!</p>';
    echo '<p><a href="'.get_permalink(get_option("woocommerce_myaccount_page_id")).'">חשבון</a> <span>|</span> <a href="'.wp_logout_url().'">התנתק</a></p>';
}

The function get_avatar result link is this: http://i2.wp.com/nivbook.odedta.com/wp-content/themes/total-child-theme-master/img/wpb-default-gravatar.png

What is http://i2.wp.com/ doing in that link and how do I get rid of it?

Thanks

  • the url looks very wrong, you should contact the author of your theme, or disable relevant plugins to make sure the fault is not with them – Mark Kaplun Feb 26 '18 at 15:09
  • Do you have Jetpack installed and active? That's one of the domains it uses for its CDN to speed up image loading. – Morgan Estes Feb 27 '18 at 4:22
  • I don't have Jetpack, no. I'll contact the author, though, that is a wordpress function. Thanks. – odedta Feb 27 '18 at 10:02
1

As the filename suggests, it's a default for when someone does not have a gravatar assigned. It is set up in your child theme and looks to be improperly set. You should search through the child theme files to find 'wpb-default-gravatar.png' and from there figure out what is adding the extra domain.

If this is a child theme you've purchased and not a custom one, I would highly recommend letting the theme author know and if you're able to solve the code problem, send them a pull request or the finished code with an explanation of what problem you were solving so they can include it in the next update.

  • I don't understand why the image is not loaded though, if you click that link it opens up in the browser and the image is visible, so why the <img> tag doesn't accept it? – odedta Feb 27 '18 at 10:05
  • What is the full HTML output? Perhaps your site settings enforce HTTPS, and since the image is on HTTP instead, it's being hidden or prevented from displaying for security reasons? – WebElaine Feb 27 '18 at 14:28
  • That's exactly the issue! what can I do? – odedta Feb 28 '18 at 9:05
  • Try turning off all of your plugins and check whether you still have the problem. If you do, it's probably a theme issue. If the issue disappears, turn on plugins one by one and test until you figure out which one it's coming from. Then contact the theme or plugin author - it's fastest if you find a fix and submit a pull request to their codebase. – WebElaine Feb 28 '18 at 14:34
0

Gravatar comes from the people of Wordpress. I don't find it weird they serve a default gravatar (which is requested from a Wordpress site) from a Wordpress domain.

Why do you want to get rid of it ?

  • What? read the question again please. – odedta Feb 27 '18 at 11:13
  • I think your theme uses some function to filter your default avatar through gravatar or so, because as morganestes already said, it's a WP domain, also used by jetpack. Search for the get_the_avatar filter in your themes or plugin. That filter might be overriding it somewhere. – Beee Feb 27 '18 at 14:32
  • It's not even in the theme files, i'll contact the theme author anyway. Thanks. – odedta Feb 28 '18 at 9:05

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.