WordPress filter hook
bp_core_fetch_avatar
Fired by 3 WordPress plugins, running on 90K+ sites between them.
“Filters an avatar URL wrapped in an <img> element.”
How to use bp_core_fetch_avatar
It's a filter: your callback receives the value and 8 more arguments, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'bp_core_fetch_avatar', function( $value, $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ) {
// Change $value here.
return $value;
}, 10, 9 );Argument names come from Jet Event System for BuddyPress's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
3 plugins that fire bp_core_fetch_avatar
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
BuddyPress90,000+ installs
apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '"' . $html_class . $html_css_id . $html_width . $html_height . $html_alt . $html_title . $extra_attr . ' />', $params, $params['item_id'], $params['avatar_dir'], $html_css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir )bp-core/bp-core-avatars.php:597 -
Jet Event System for BuddyPress10+ installs
apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir )main/jet-events-templatetags.php:434 -
u-wordpressFewer than 10 installs
apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir )bp-core-avatars.php:198
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.