Make WordPress Core

Opened 12 years ago

Closed 10 years ago

#21930 closed enhancement (duplicate)

Allow hooks to define avatar before Gravatar processing

Reported by: jakemgold's profile jakemgold Owned by:
Milestone: Priority: normal
Severity: trivial Version: 3.4
Component: Users Keywords: has-patch
Focuses: Cc:


The get_avatar() function allows for developers to override avatar output in two ways. You can replace the function (pluggable) - not a good idea in my view, especially if you still want the ability to fallback and use Gravatar sometimes. You can also filter the output at the very end of the function with the 'get_avatar' hook. This works fine, but in highly common instances where a plug-in might want to override the avatar on a case by case basis, this forces each get_avatar call to needlessly process through the entire default avatar / Gravatar "construction".

Admittedly, that processing is mostly trivial string manipulation and conditionals with an md5 in the mix, but it still seems like needless overhead in instances where many avatars might get called in a comments thread or authors list.

Proposing a pretty trivial change that allows an avatar to be defined by a filter hook before proceeding through Gravatar / default avatar processing, skipping over all of that if one is, in fact, defined.

My inspiration for this is an attempt to improve the performance of my fairly popular Simple Local Avatars plug-in, that allows users to upload local avatars:

Attachments (1)

pluggable.php.patch (800 bytes) - added by jakemgold 12 years ago.
Proposed changeset

Download all attachments as: .zip

Change History (6)

12 years ago

Proposed changeset

#2 @Otto42
12 years ago

  • Cc Otto42 added

#3 @SergeyBiryukov
12 years ago

  • Version changed from trunk to 3.4

#4 @DrewAPicture
12 years ago

  • Cc xoodrew@… added


#5 @DrewAPicture
10 years ago

  • Component changed from General to Users
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Closing as a duplicate of #21195 as it has a much more complete solution that accomplishes the same goal proposed by this ticket.

Note: See TracTickets for help on using tickets.