Skip to:

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#6622 closed defect (bug) (fixed)

Missed $args parameter in bp_core_fetch_avatar_filter()

Reported by: weddywood's profile WeddyWood Owned by: r-a-y's profile r-a-y
Milestone: 2.4 Priority: high
Severity: normal Version: 2.3.0
Component: Media Keywords: has-patch


$args parameter is missed in bp_core_fetch_avatar_filter() function, however this parameter exist in default get_avatar() WordPress function. Thus it is impossible to use class (for example) parameter for avatar.

Default WordPress get_avatar() function accept setting this $args parameter in filter:

apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args );

Therefore now bp_core_fetch_avatar_filter() function breaks default get_avatar behaviour.

Attachments (2)

6622.01.patch (4.9 KB) - added by r-a-y 9 years ago.
6622.02.patch (8.9 KB) - added by r-a-y 9 years ago.

Download all attachments as: .zip

Change History (10)

#1 @DJPaul
9 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to 2.4
  • Priority changed from normal to high

Hi WeddyWood

The $args parameter was added recently in WordPress 4.2, and it looks like no-one in BP noticed. We can add it in, sure. Thanks for pointing it out. :)

9 years ago

#2 @r-a-y
9 years ago

  • Keywords has-patch added; needs-patch removed

01.patch is an initial pass at supporting the new $args parameter in the 'get_avatar' filter.

Something to be wary about is the $args['extra_attr'] parameter. WP does not sanitize this whatsoever. Do we want to do anything here?

This ticket was mentioned in Slack in #buddypress by boone. View the logs.

9 years ago

#4 @DJPaul
9 years ago

  • Keywords commit added

I don't think BuddyPress would have made that decision if we were implementing that, but as WordPress didn't and it is their filter, we shouldn't either.

I think your patch is fine. The only thing I suggest is to add a @since 2.4 Added $args parameter on the bp_core_fetch_avatar_filter function.

9 years ago

#5 @r-a-y
9 years ago

  • Keywords good-first-bug commit removed
  • Version changed from 2.3.3 to 2.3.0

02.patch is updated to include more parameters from WordPress 4.2.0:

Just need a once-over before committing.

#6 @boonebgorges
9 years ago

02.patch looks good to me1

#7 @r-a-y
9 years ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 10287:

Avatars: Support new parameters from WordPress 4.2.0 when filtering 'get_avatar'.

WordPress 4.2.0 added a new parameter - $args - to their 'get_avatar'
filter. This $args parameter is an array that houses additional options
including the width, height and CSS class, as well as the following

  • 'extra_attr' - unsanitized HTML attributes to add to the <img> element.
  • 'scheme' - URL scheme to use.
  • 'rating' - Gravatar rating.
  • 'force_default' - Only applicable to Gravatars. Always use the default image even if a valid Gravatar exists.

Consequently, bp_core_fetch_avatar() now supports the listed options
above as well.

Fixes #6622.

#8 @DJPaul
8 years ago

  • Component changed from API - Avatars to Media
Note: See TracTickets for help on using tickets.