Skip to:
Content

BuddyPress.org

Opened 4 months ago

Last modified 4 months ago

#8267 new enhancement

Storing avatar information into usermeta

Reported by: stokim Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Core Keywords:
Cc:

Description

Hi there!
I'm looking forward to 6.0, however there are few more things to add.
First, how about storing avatar information into DB, especially filename.
Now, to get avatar url, we have to use functions such as file_exist, readdir, closedir etc.
How about just storing avatar filename generated random id into usermeta?
I found this thread: https://buddypress.trac.wordpress.org/ticket/4237
However for 8 years, it has not been changed at all.
I know accessing db is costly, however it would be better to use DB instead of using those functions.
If we can store filename into usermeta, we can use this with attaching -thumb and -full with ease. Thank you.

Attachments (1)

avatar.patch (629 bytes) - added by stokim 4 months ago.

Download all attachments as: .zip

Change History (3)

@stokim
4 months ago

#1 @stokim
4 months ago

Only one line can change the way of fetching an avatar URL from directory check to DB inquiry.

Last edited 4 months ago by stokim (previous) (diff)

#2 @stokim
4 months ago

$serialized_avatar_url = get_user_meta( $user_id, 'avatar_url', true );
$avatar_url = $serialized_avatar_url ? maybe_unserialize( $serialized_avatar_url ) : null;
You can get both size's url through $avatar_url['thumb'] and $avatar_url['full'];
Note: See TracTickets for help on using tickets.