[buddypress-trac] [BuddyPress] #4237: Adding avatar file names to db

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Thu Jun 7 01:13:47 UTC 2012

#4237: Adding avatar file names to db
 Reporter:  modemlooper        |       Owner:
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Core               |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |

Comment (by r-a-y):

 Hmm... for your use case, I would probably cache the avatar URL when a
 user uploads a new avatar.

 Something like:

 // totally untested!
 function my_cache_avatar_url() {
         update_user_meta( bp_displayed_user_id(),
 'modemloopers_awesome_avatar_url', bp_core_fetch_avatar(
 'html=false&item_id=' . bp_displayed_user_id() ) );
 add_action( 'xprofile_screen_change_avatar', 'my_cache_avatar_url' );

 Then you can reference the avatar URL via user meta.

 The caveat here is this is done on a case-by-case basis.  If you need to
 do this for every user (at least initially), you'd have to write a script
 to loop through the user avatars directory and cache it that way.

 You also need to remove the avatar from user meta if the user has deleted

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4237#comment:3>
BuddyPress <http://buddypress.org/>

More information about the buddypress-trac mailing list