Skip to:
Content

BuddyPress.org

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#2436 closed enhancement (fixed)

Make it easy to just get the avatar URL

Reported by: hempsworth's profile hempsworth Owned by: hempsworth's profile hempsworth
Milestone: 1.2.5 Priority: normal
Severity: Version:
Component: Core Keywords: has-patch
Cc: hempsworth@…

Description

There is no easy way to just get the avatar URL, all of the available methods:

bp_displayed_user_avatar()
bp_loggedin_user_avatar()
bp_core_fetch_avatar()

all return the entire <img>. I've slightly modified these functions to allow just the URL to be outputted. Completely backwards compatible, and negates the need for hacks like this.

Now, to get the URL all you need to do is:

bp_displayed_user_avatar( 'url=true' );
bp_loggedin_user_avatar( 'url=true' );

Attachments (1)

add_url_parameter.diff (3.8 KB) - added by hempsworth 14 years ago.

Download all attachments as: .zip

Change History (4)

#1 @hempsworth
14 years ago

  • Cc hempsworth@… added
  • Owner set to hempsworth
  • Status changed from new to accepted

#2 @johnjamesjacoby
14 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [3086]) Fixes #2436 and adds some documentation to bp_core_fetch_avatar

#3 @johnjamesjacoby
14 years ago

hempsworth: The $html argument was added, and set to true by default.

If you use...

bp_core_fetch_avatar( array( 'html' => false ) );

...you will simply return the URL of the avatar with no <img>

Note: See TracTickets for help on using tickets.