Airplane_Mode_Core::replace_gravatar PHP Method

replace_gravatar() public method

Replace all instances of gravatar with a local image file to remove the call to remote service.
public replace_gravatar ( string $avatar, integer | object | string $id_or_email, integer $size, string $default, string $alt ) : string
$avatar string Image tag for the user's avatar.
$id_or_email integer | object | string A user ID, email address, or comment object.
$size integer Square avatar width and height in pixels to retrieve.
$default string URL to a default image to use if no avatar is available.
$alt string Alternative text to use in the avatar image tag.
return string `` tag for the user's avatar.
        public function replace_gravatar($avatar, $id_or_email, $size, $default, $alt)
        {
            // Bail if disabled.
            if (!$this->enabled()) {
                return $avatar;
            }
            // Swap out the file for a base64 encoded image.
            $image = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
            $avatar = "<img alt='{$alt}' src='{$image}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' style='background:#eee;' />";
            // Return the avatar.
            return $avatar;
        }