Example #1
0
function revert_to_default_wp_avatar($img, $params, $item_id)
{
    // we are concerned only with users
    if ($params['object'] != 'user') {
        return $img;
    }
    //check if user has uploaded an avatar
    //if not then revert back to wordpress core get_avatar method
    //remove the filter first, or else it will go in infinite loop
    remove_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    if (!userpro_user_has_avatar($item_id)) {
        $width = $params['width'];
        // Set image width
        if (false !== $width) {
            $img_width = $width;
        } elseif ('thumb' == $type) {
            $img_width = bp_core_avatar_thumb_width();
        } else {
            $img_width = bp_core_avatar_full_width();
        }
        $img = get_avatar($item_id, $img_width);
    }
    //add the filter back again
    add_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    return $img;
}
Example #2
0
function revert_to_default_wp_avatar($img, $params, $item_id)
{
    if ($params['object'] != 'user') {
        return $img;
    }
    remove_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    if (!userpro_user_has_avatar($item_id)) {
        $width = $params['width'];
        if (false !== $width) {
            $img_width = $width;
        } elseif ('thumb' == $params['type']) {
            $img_width = bp_core_avatar_thumb_width();
        } else {
            $img_width = bp_core_avatar_full_width();
        }
        $img = get_avatar($item_id, $img_width);
    }
    add_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    return $img;
}