#7424 closed defect (bug) (fixed)
filter get_avatar_url to parse URLs from BP avatars
Reported by: | elhardoum | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 2.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Extended Profile | Keywords: | has-patch commit |
Cc: |
Description
Hello,
This is my very first ticket and I hope I am not breaking something.
BuddyPress is [filtering](https://buddypress.trac.wordpress.org/browser/tags/2.7.4/src/bp-core/bp-core-avatars.php#L1466) [get_avatar()
](https://developer.wordpress.org/reference/functions/get_avatar/) correctly to parse the custom avatars uploaded via member profile which is neat. However, it is not filtering [get_avatar_url()
](https://developer.wordpress.org/reference/functions/get_avatar_url/) which is a WP function which basically used in most themes or plugins to get the avatar URLs easily rather than to decode the HTML output of get_avatar to get the image source attribute (src
).
I hope this makes sense. Here's a paste of code for this filter http://pastebin.com/nQEEa7De
Thanks,
Samuel
Attachments (3)
Change History (18)
#1
@
8 years ago
- Component changed from Core to Extended Profile
- Milestone changed from Awaiting Review to 2.9
#2
@
7 years ago
01.patch
deprecates the older bp_core_fetch_avatar_filter()
function in favor for the added bp_core_get_avatar_data_filter()
function.
bp_core_get_avatar_data_filter()
hooks to the newer 'get_avatar_data'
filter available since WordPress 4.2. The 'get_avatar_data'
filter should also cover the 'get_avatar_url'
filter.
The reason for deprecation is BP 2.9 supports a minimum of WP 4.4 and the 'get_avatar'
filter is old. The get_avatar()
function itself uses get_avatar_data()
.
#3
@
7 years ago
01.patch
filters 'get_avatar_data'
.
02.patch
filters 'get_avatar_url'
instead. This might be more preferable since 'get_avatar_data'
fires after the 'get_avatar_url'
filter.
#4
@
7 years ago
@r-a-y This is a first patch ticket, is your update commit ready or should I apologize profusely to @elhardoum in having to punt this to 3.0 with the promise of an 'early' tag?
This ticket was mentioned in Slack in #buddypress by r-a-y. View the logs.
7 years ago
#7
@
7 years ago
- Owner set to boonebgorges
- Resolution set to fixed
- Status changed from new to closed
In 11614:
#8
@
7 years ago
Thanks @boone, @r-a-y and congrats @elhardoum your first ticket/patch is committed.
#9
@
7 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
- Type changed from enhancement to defect (bug)
Function bp_core_get_avatar_data_url_filter in the patch return null when the second param $id_or_email is an email address.
Here is the Code: [bp-core/bp-core-avatars.php#L1378](https://buddypress.trac.wordpress.org/browser/trunk/src/bp-core/bp-core-avatars.php#L1374)
Just add this code to line 1380 would fix this bug
} elseif (is_string( $id_or_email )) {
$user = get_user_by( 'email', $id_or_email );
Thanks for the suggestion and your patch. This is a new function introduced very recently into WordPress, which is why we don't have historical support.
We'll look into this soon, but it probably won't make a BuddyPress shipping release for another 3-4 months (we're very near to releasing BuddyPress version 2.8, so it's unfortunate timing).