[wp-trac] [WordPress Trac] #12291: floated_admin_avatar makes it difficult to use other avatars

WordPress Trac wp-trac at lists.automattic.com
Fri Feb 19 19:12:29 UTC 2010


#12291: floated_admin_avatar makes it difficult to use other avatars
----------------------------+-----------------------------------------------
 Reporter:  Otto42          |       Owner:       
     Type:  defect (bug)    |      Status:  new  
 Priority:  normal          |   Milestone:  3.0  
Component:  Administration  |     Version:  2.9.2
 Severity:  normal          |    Keywords:       
----------------------------+-----------------------------------------------
 The get_avatar function is quite clever. It can take several different
 types of input and produce a correct gravatar from it.

 The three main things it accepts are: user ID,  email address, and a
 comment object.

 A function called "floated_admin_avatar" in wp-admin/includes/comment.php
 hooks itself onto the "comment_author" filter in the admin sections. The
 purpose of it is to float a tiny little avatar image anywhere the comment
 author name appears in the admin.

 The problem is that the floated_admin_avatar function doesn't let the
 get_avatar function do its job. Instead, the floated_admin_avatar function
 looks at the comment object and pulls out the email or user id to pass
 down to get_avatar.

 The end result of this is that comment avatars displayed in the admin
 section are always generated without having the full comment available to
 them.

 This is a problem for plugins that want to modify comment avatars using
 other data.

 For example, if a plugin were to tag a comment as having come from a
 specific facebook user, then it could hook the get_avatar filter,
 recognize the comment as having been made by a facebook user (perhaps
 using the comment metadata), and then change the avatar to a facebook
 avatar instead of a gravatar.

 But plugins can only do that when they receive the entire comment. If it's
 getting just an email address, then there's no way for it to recognize
 what's what.

 In other words, floated_admin_avatar() needs to stop looking inside the
 $comment and passing a string or number to get_avatar. This is so my
 Facebook and Twitter plugins can display avatars in the admin via the
 simple filters which they already have instead of having to go to absurd
 lengths by manually disconnecting the floated_admin_avatar function.

 All that needs to happen is for this to replace the existing function and
 fix the problem:

 {{{
 function floated_admin_avatar( $name ) {
         global $comment;
         $avatar = get_avatar( $comment, 32 );
         return "$avatar $name";
 }
 }}}

 Simple. Works. And it lets plugins do what they were supposed to do.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12291>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list