WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Remove Gravatar calls from pluggable.php? (5 posts)

  1. a_johnson
    Member
    Posted 2 years ago #

    I noticed that on two web sites I manage that the page loads always hang on the Gravatar.

    Neither site has a blog but uses Wordrpress as a CMS. I opened as many files as I thought necessary and see pluggable.php is the one that contains the gravatar links.

    Since I don't actually need Gravatars, can I just remove the six references to Gravatar?

    Lines are 1703, 1706, 1708, 1712, 1715, and 1717. I realize that I will probably need to do this over again when WP is updated.

  2. Paul Clark
    Member
    Posted 2 years ago #

    No need to hack core. The function you're looking at, get_avatar(), provides two options for changing what displays for the avatars.

    1. get_option('show_avatars') at the start. Turn this option off to disable all avatars. No Gravatar images will be outputted.
    2. apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt); at the end. This allows you to override the generated HTML with anything you want. No actual calls are made to gravatar in the get_avatar() function. Instead, the calls are made when a gravatar URL is outputted in HTML. This filter allows you to change that HTML before it's put on the page.

    You can find examples of using that filter to override avatar behavior here and here.

  3. a_johnson
    Member
    Posted 2 years ago #

    Turning off the avatars didn't help. I still get read 1.gravatars.com in the progress bar. I removed a div from two of the page templates to see if that helped but it didn't either.

  4. a_johnson
    Member
    Posted 2 years ago #

    add_filter('get_avatar', 'get_no_gravatar', 1, 2);
    function get_no_gravatar( $id_or_email, $size = '96', $default = '', $alt = false ) {
       // put your new function in here
            $avatar = "<img alt='image_alt' src='#' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
    	return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
    };

    From another post, I put this in theme functions and it worked. The page no longer hangs on gravatar.com

  5. Paul Clark
    Member
    Posted 2 years ago #

    Looks good, but you might want just return $avatar. I would think running apply_filters('get_avatar') inside a function that's applied to that hook would cause an infinite loop.

Topic Closed

This topic has been closed to new replies.

About this Topic