Make WordPress Core

Opened 17 years ago

Closed 17 years ago

Last modified 3 years ago

#5775 closed enhancement (fixed)

Pluggable get_avatar()

Reported by: ryan's profile ryan Owned by: ryan's profile ryan
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.5
Component: General Keywords: avatar
Focuses: 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 (3)

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

Download all attachments as: .zip

Change History (23)

#1 @ryan
17 years ago

Sample implementation. Not yet tested.

#2 @DD32
17 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)

#3 @ryan
17 years ago

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

#4 @DD32
17 years ago

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

Ah ok.

#5 @josephscott
17 years ago

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

@ryan
17 years ago

#6 @ryan
17 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.

#7 @ryan
17 years ago

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

#8 @Viper007Bond
17 years ago

  • 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.

#9 @ryan
17 years ago

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

#10 @ryan
17 years ago

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

#11 @ryan
17 years ago

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.

@Viper007Bond
17 years ago

Save a couple CPU cycles

#12 @ryan
17 years ago

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

#13 @JeremyVisser
17 years ago

  • 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.

#14 follow-up: @ryan
17 years ago

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

#15 @ryan
17 years ago

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

#16 @ryan
17 years ago

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

#17 @spikeyslam
17 years ago

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

@spikeyslam
17 years ago

urlencode($default) when needed

#18 @ryan
17 years ago

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

#19 in reply to: ↑ 14 @djr
17 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

#20 @matt
17 years ago

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