Make WordPress Core

Opened 6 years ago

Last modified 4 months ago

#48088 new enhancement

Anonymous Avatar should be served locally

Reported by: dshanske's profile dshanske Owned by:
Milestone: Future Release Priority: low
Severity: normal Version:
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

Right now, even the mystery man is retrieved by querying gravatar.

We should have a local copy of the anonymous avatar that is served.

At the least, if there is no requirement for an email, which is what is used to provide the gravatar requests, why make requests to gravatar?

We could say caching gravatar responses is plugin territory, and while I would like to do with with gravatar for performance, this is about not making a call in the first place.

Change History (2)

#1 @andraganescu
6 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Hi @dshanske I think you are correct, as this is not a matter of caching avatars, it is simply a default asset which should be served locally.

This ticket was mentioned in PR #9354 on WordPress/wordpress-develop by @akshat2802.


4 months ago
#2

  • Keywords has-patch added; needs-patch removed

Trac ticket: https://core.trac.wordpress.org/ticket/48088

This PR enhances the get_avatar_data() function by serving a local default avatar (the Mystery Man) when no email or hash is available, thereby avoiding unnecessary external requests to Gravatar.

### What This PR Does

  • Adds a short-circuit in get_avatar_data():
  • A local image is served instead of calling Gravatar.
  • Introduces a new image asset:

wp-includes/images/avatar-default.png (256x256)

### How to Test

  • Call get_avatar() with:

echo get_avatar( '', 96, 'mm' );

  • The returned URL should point to includes_url( 'images/avatar-default.png' ).
  • The browser should display the local image (mystery avatar).
  • Requests with valid emails will continue to use Gravatar normally.
Note: See TracTickets for help on using tickets.