Ticket #5775 (closed enhancement: fixed)

Opened 4 years ago

Last modified 4 years ago

Pluggable get_avatar()

Reported by: ryan Owned by: ryan
Priority: normal Milestone: 2.5
Component: General Version: 2.5
Severity: normal Keywords: avatar
Cc:

Description

So that themes can rely on an avatar function always being available, let's introduce a get_avatar() pluggable function. By default it can use gravatar (disclaimer, my company owns gravatar), but plugins can replace the function altogether or hook onto a filter to use a different service. We might need new options to select avatar rating and allow avatars to not be displayed at all.

Attachments

get_avatar.diff Download (1.3 KB) - added by ryan 4 years ago.
md5hash.patch Download (600 bytes) - added by Viper007Bond 4 years ago.
Save a couple CPU cycles
5775-urlencode.patch Download (777 bytes) - added by spikeyslam 4 years ago.
urlencode($default) when needed

Change History

comment:1   ryan4 years ago

Sample implementation. Not yet tested.

comment:2   DD324 years ago

apologies for the off-topic: With Gravatar, would it be possible in the future to allow setting it for a domain? I use contact+<sitename>@host for most commenting/signing up to blogs.. So its utterly useless to me at present :P

As to this ticket, It sounds like a good idea for themes, but, i feel by default it might be best not to have the gravatar stuff in there, I'd like it to be linked to my wordpress.com username instead somehow, if that means i have to add a plugin to enable wordpress.com integration, or add a plugin to enable gravaar integration then thats fine by me, so maybe WordPress should just have a stub in place?

(But In other words, I'd rather it linked to wordpress.com than gravatar.com)

comment:3   ryan4 years ago

wordpress.com doesn't have any external avatar lookup. wordpress.com avatars might someday be served from gravatar anyway.

comment:4   DD324 years ago

wordpress.com doesn't have any external avatar lookup. wordpress.com avatars might someday be served from gravatar anyway.

Ah ok.

I haven't seen any way to set the avatar_rating option yet.

ryan4 years ago

comment:6   ryan4 years ago

The UI isn't there yet. I'm thinking of "Show Avatars" <yes|no> and "Show Avatars Rated:" <g|pg|r|x> options in Options->Reading. I can rough in something and let the designers decide on layout and wording.

I updated the patch to return false if the 'show_avatars' option is not true. Themes would need to check for a false return and style accordingly.

comment:7   ryan4 years ago

(In [6748]) get_avatar(). see #5775

  • Version set to 2.5

"Show Avatars Rated" should be more clear. I know what it means, but noobs may not. Either that, it needs some explanation text.

comment:9   ryan4 years ago

Agreed. I'm just roughing it in for now. Suggestions welcome.

(In [6749]) Gonna serve default avatars from gravatar. see #5775

Removed the default avatar images. We're going to serve those off of gravatar. The images aren't on gravatar yet so the gravatar branded default will show for now.

Save a couple CPU cycles

(In [6756]) Precompute the hash of the unknown avatar user to save an md5 call. Props Viper007Bond. see #5775

  • Type changed from defect to enhancement

Shouldn't the "Don't show Avatars" / "Show Avatars" option box be a checkbox instead?

Or is there an intention to add more options to this box? If not, it should definitely become a checkbox.

comment:14 follow-up: ↓ 19   ryan4 years ago

A checkbox is fine. Anyone want to patch it up? Also, anyone have a suggestion for better text than "Show Avatars Rated"?

(In [6945]) Allow comment object to be passed to get_avatar() for convenience. see #5775

(In [6946]) Allow comment object to be passed to get_avatar() for convenience. see #5775

$default is getting urlencoded to soon and prevents usage as an img src later in the function.

urlencode($default) when needed

(In [7096]) urlencode only when needed. Props spikeyslam. see #5775

comment:19 in reply to: ↑ 14   djr4 years ago

Replying to ryan:

A checkbox is fine. Anyone want to patch it up? Also, anyone have a suggestion for better text than "Show Avatars Rated"?

Choose Avatar rating

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.