Search Results for 'bp_core_fetch_avatar'
-
AuthorSearch Results
-
November 8, 2010 at 1:43 pm #97733
In reply to: How to disable Gravatar completely?
Javier ArquesParticipantHi @BuddyPresser !
I have found out another way get it not editing core files. Put this filter into your functions.php file:`function bp_remove_gravatar ($image, $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir) {
$default = ‘http://yoursite.net/wp-content/plugins/buddypress/bp-core/images/mystery-man.jpg’;
if( $image && strpos( $image, “gravatar.com” ) ){
return ‘‘;
}else
return $image;}
add_filter(‘bp_core_fetch_avatar’, ‘bp_remove_gravatar’, 1, 9 );function remove_gravatar ($avatar, $id_or_email, $size, $default, $alt) {
$default = ‘http://yoursite.net/wp-content/plugins/buddypress/bp-core/images/mystery-man.jpg’;
return ““;
}add_filter(‘get_avatar’, ‘remove_gravatar’, 1, 5);
`It worked for me
November 1, 2010 at 3:22 pm #97121In reply to: Getting rid of Gravatars …
Boone GorgesKeymasterCool, I’m glad the first part worked!
Here’s a thrown-together-in-five-minutes filter to replace missing avatars with BP’s default mystery man. This probably won’t differentiate between user and group avatars, which you’ll have to sniff out of the $params array (in sort of the same way that I do with width and height). The basic idea is: if bp_core_fetch_avatar is not outputting any HTML, swap out the boolean false with the default mystery man.
`function bbg_no_avatar( $html, $params ) {
if ( !$html ) {
if ( $params )
$height = ‘ height=”‘ . $params . ‘”‘;if ( $params )
$height = ‘ width=”‘ . $params . ‘”‘;$default_image_url = WP_PLUGIN_URL . ‘/buddypress/bp-core/images/mystery-man.jpg’;
$html = ‘‘;
}return $html;
}
add_action( ‘bp_core_fetch_avatar’, ‘bbg_no_avatar’, 10, 2 );`November 1, 2010 at 11:44 am #97104In reply to: Getting rid of Gravatars …
mistercyrilParticipantHello Boone,
So step 1 WORKS!
Hooray This was pretty simple, i’m sorry I couldn’t find it on my own.As far as step 2 is concerned
You are right, previous users who had the mistery man icon don’t have an avatar anymore.
I took a look at the ‘bp_core_fetch_avatar’ section but i’m not quite sure how to write the filter you mentioned.
Could I abuse of your help and ask for an example? Would really be great.Thank you,
C.October 30, 2010 at 2:42 pm #96997In reply to: Getting rid of Gravatars …
Boone GorgesKeymasterAt the moment, there is no easy way to turn off Gravatar. I agree that there should be an easy way, as there can be performance concerns, as @mistercyril. (Though I find “I’m starting to think I’m the only one concerned with performance” unnecessarily confrontational.) I’ve had issues with it in the past myself.
I’ve just opened a ticket to make disabling Gravatar easier: https://trac.buddypress.org/ticket/2697 Until it’s been implemented, here’s the general core-hack strategy for disabling Gravatar altogether:
1) In bp-core/bp-core-avatars.php, find where the $defaults for bp_core_fetch_avatar() are set. Change
`’no_grav’ => false,`
to
`’no_grav’ => true,`2) There will likely be some instances where the Mystery Man doesn’t kick in properly (group avatars, existing users). Write a filter for `’bp_core_fetch_avatar’` that sets the avatar to some default value when no avatar is returned.
October 13, 2010 at 11:14 am #95043LawrenceParticipantHey guys,
Just letting everyone know I’ve finally made progress on this: I now have custom avatars for Buddypress – the code needs tidying up, but its pretty much there. If all else fails then it reverts to the mysteryman. At the moment I’m trying to see if I can set a male/female setting, so when users sign up it can auto-generate dependent on their gender.
Should note it filters bp_core_fetch_avatar, so if someone uses a gravatar then it’ll show accordingly.
Anyone interested in this as a plugin? The theory is that I’m going to do various different graphics/styles so people can ultimately choose or design their own avatars “parts”. Might need someone look over my code though – its rough at best. I could also see this as quite a nice official implementation in the core as I’m sure designers would like to extend the avatar system.
Some screenshots:
http://www.obscuresounds.com/output.png
http://www.obscuresounds.com/avatar-screenshot.jpgSeptember 20, 2010 at 6:43 pm #92953caplainMemberThanks. I figured it out while waiting, even though your response was immediate
$group = new BP_Groups_Group( 1, true );
$avatar = bp_core_fetch_avatar(
array(
‘item_id’ => 1,
‘object’ => ‘group’,
‘type’ => ‘full’,
‘avatar_dir’ => ‘group-avatars’,
‘alt’ => ‘Group Avatar’,
‘css_id’ => 0,
‘class’ => ‘avatar’,
‘width’ => false,
‘height’ => false
)
);echo $avatar . “
“;
echo ‘slug.’/”>’.$group->name.’
‘.$group->description;September 20, 2010 at 5:31 pm #92937Boone GorgesKeymasterTry this:
`$group = new BP_Groups_Group( $group_id );`$group will then be an object containing the group name and a few other pieces of info. You’ll need to use bp_core_fetch_avatar() to get the avatar.
September 19, 2010 at 7:07 am #92841omoshaParticipantYeah, I’m still getting the error message
‘Warning: Missing argument 5 for bp_core_fetch_avatar_filter() in /home/integral/public_html/wp-content/plugins/buddypress/bp-core/bp-core-avatars.php on line 479’and I’ve removed step 3 from https://codex.buddypress.org/getting-started/install-buddypress-on-a-secondary-blog/
Have you ever run into this or have any idea how to fix?
Thanks again for checking it out
September 18, 2010 at 7:48 pm #92814omoshaParticipantThank you so much, Mercime! I’ve got most of it all installed with the exception of a few hiccups.
I had a difficult time with the avatars even before this modification. I’m getting this error code
‘/home/integral/public_html/wp-content/plugins/buddypress/bp-core/bp-core-avatars.php on line 479’
When I go into bp-core-avatars.php on line 479 I see this as the definition:
‘function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt ) {// If passed an object, assume $user->user_id
if ( is_object( $user ) )
$id = $user->user_id;// If passed a number, assume it was a $user_id
else if ( is_numeric( $user ) )
$id = $user;// If passed a string and that string returns a user, get the $id
else if ( is_string( $user ) && ( $user_by_email = get_user_by_email( $user ) ) )
$id = $user_by_email->ID;// If somehow $id hasn’t been assigned, return the result of get_avatar
if ( empty( $id ) )
return !empty( $avatar ) ? $avatar : $default;// Let BuddyPress handle the fetching of the avatar
$bp_avatar = bp_core_fetch_avatar( array( ‘item_id’ => $id, ‘width’ => $size, ‘height’ => $size, ‘alt’ => $alt ) );// If BuddyPress found an avatar, use it. If not, use the result of get_avatar
return ( !$bp_avatar ) ? $avatar : $bp_avatar;
}’I’ve tried installing a bp-custom.php file within the plugin directory so that it would not be deleted when updating Buddypress but it produces an error everywhere on the site.
Here is what I tried to add as the bp-custom.php file for reference:
‘define( ‘BP_AVATAR_UPLOAD_PATH’, ‘/var/www/wp-content/blogs.dir/1/files’ );
define( ‘BP_AVATAR_URL’, ‘hxxp://integralbeings.com/files’ );’As I look at the code, I’m wondering if this is because there is no hxxp://integralbeings.com/files directory. Do I need to add this or is the path incorrect? Also, I’ve not seen hxxp before, is this a typo?
Thanks for the support on this, it’s rather minor in the grand scheme of things, but I’m wondering if it will become a bigger problem as the community grows.
Cheers,
-BrantSeptember 12, 2010 at 9:18 pm #92253Justin FrydmanParticipantThank you both for your help, so I’m hoping I can return the favor. Modemlooper, here is how I adjusted the My Friends tab, but it has sub nav code for you, maybe it will help. Credit for this from @jeffsayre
`function my_friends_setup_nav() {
global $bp;/* Add ‘Friends’ to the main navigation */
if( bp_friend_get_total_requests_count($disp_user) > 0 && bp_is_my_profile()) {
bp_core_new_nav_item( array( ‘name’ => sprintf( __( ‘Friends (%d) (%d)‘, ‘buddypress’ ), friends_get_total_friend_count(), bp_friend_get_total_requests_count() ), ‘slug’ => $bp->friends->slug, ‘position’ => 60, ‘screen_function’ => ‘friends_screen_my_friends’, ‘default_subnav_slug’ => ‘my-friends’, ‘item_css_id’ => $bp->friends->id ) );
} else {
bp_core_new_nav_item( array( ‘name’ => sprintf( __( ‘Friends (%d)‘, ‘buddypress’ ), friends_get_total_friend_count() ), ‘slug’ => $bp->friends->slug, ‘position’ => 60, ‘screen_function’ => ‘friends_screen_my_friends’, ‘default_subnav_slug’ => ‘my-friends’, ‘item_css_id’ => $bp->friends->id ) );
}$friends_link = $bp->loggedin_user->domain . $bp->friends->slug . ‘/’;
/* Add the subnav items to the friends nav item */
bp_core_new_subnav_item( array( ‘name’ => __( ‘My Friends’, ‘buddypress’ ), ‘slug’ => ‘my-friends’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_my_friends’, ‘position’ => 10, ‘item_css_id’ => ‘friends-my-friends’ ) );
bp_core_new_subnav_item( array( ‘name’ => sprintf( __( ‘Requests (%d)‘, ‘buddypress’ ), bp_friend_get_total_requests_count() ), ‘slug’ => ‘requests’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_requests’, ‘position’ => 20, ‘user_has_access’ => bp_is_my_profile() ) );if ( $bp->current_component == $bp->friends->slug ) {
if ( bp_is_my_profile() ) {
$bp->bp_options_title = __( ‘My Friends’, ‘buddypress’ );
} else {
$bp->bp_options_avatar = bp_core_fetch_avatar( array( ‘item_id’ => $bp->displayed_user->id, ‘type’ => ‘thumb’ ) );
$bp->bp_options_title = $bp->displayed_user->fullname;
}
}do_action( ‘friends_setup_nav’ );
}add_action( ‘bp_setup_nav’, ‘my_friends_setup_nav’, 11 );`
August 24, 2010 at 4:49 am #90139In reply to: group default avatar
r-a-yKeymasterSince you’re using the filter I posted, I would manually setup a group loop. Then in this loop, I would use the bp_core_fetch_avatar() function with the “html” parameter set to false (view the full function and parameter list in /bp-core/bp-core-avatars.php).
Doing this will return the URL of the avatar, then you can manually define the width and height in an IMG tag.
August 23, 2010 at 8:39 pm #90093In reply to: How to Override the BuddyPress Avatar Override
r-a-yKeymasterseobrien –
Read this: http://wpmu.org/how-to-add-a-custom-default-avatar-for-buddypress-members-and-groups/iamnorthwind –
If you’re using another plugin to upload avatars, you’ll need to override the way BuddyPress fetches avatars.Specifically, you’ll need to override the “bp_core_fetch_avatar” filter located in /buddypress/bp-core-avatars.php file.
Need a primer on filters? Read this:
https://codex.wordpress.org/Plugin_API#FiltersAugust 21, 2010 at 7:15 am #89890warutParticipant@Pisanojm here are temp solution. However I see your extend profile not show in badge, I will check that too but in about 3 days (no computer in my new home – -“).
temp solution:
— replace —
if ( get_site_option(‘bp_badge_showthumbimage’) == true ) {
$avatar_html = bp_core_fetch_avatar( array( ‘item_id’ => $bp->displayed_user->id, ‘type’ => ‘thumb’, ‘alt’ => __( ”, ‘buddypress’ ) ) );
} else {
$avatar_html = bp_core_fetch_avatar( array( ‘item_id’ => $bp->displayed_user->id, ‘type’ => ‘full’, ‘alt’ => __( ”, ‘buddypress’ ) ) );
}
preg_match_all(“//i”, $avatar_html, $avatar_url);— with —
if ( get_site_option(‘bp_badge_showthumbimage’) == true ) {
$avatar_url = bp_get_loggedin_user_avatar( ‘html=false&type=thumb’ );
} else {
$avatar_url = bp_get_loggedin_user_avatar( ‘html=false&type=full’ );
}
and
search “$avatar_url[2][0]” replace with “$avatar_url”for others i will try upload new release next week.
August 17, 2010 at 3:13 pm #89393In reply to: Gravatar Settings?
Roger CoathupParticipant@lunakm: rather than modifying the core code, which will need changing every time BP is upgraded, you might be better trying to do it as a filter.
I suspect the filter you’d want to work with is bp_core_fetch_avatar_url. Try hooking a function onto this (in your bp-custom.php file) that appends the &r=x to the url.
It might be worth raising it as an enhancement request for future BP releases, to give more control over the parameters that can be passed to Gravatar.
Cheers, Roger
August 6, 2010 at 5:17 pm #88270r-a-yKeymasterTo remove FB avatars from the FB plugin, add the following to your theme’s functions.php:
remove_filter( 'bp_core_fetch_avatar', 'jfb_get_facebook_avatar', 10, 4 );
To have an option between either the BP avatar and the FB avatar, some custom code would be needed to display an admin option in the user’s settings page.
July 31, 2010 at 2:17 am #87553In reply to: Is it possible to get only the avatar-url ?
techguyParticipant@odiggy Try the Donate button on one of r-a-y’s plugins: https://buddypress.org/community/groups/oembed-for-buddypress/
r-a-y, Thanks for the extra answer. I started trying to document some of the bp_core_fetch_avatar function so that I could add it to the codex: https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/changing-avatar-size-sometimes-creates-fuzzy-avatars/ This is a good addition.
July 30, 2010 at 4:44 pm #87509In reply to: Is it possible to get only the avatar-url ?
r-a-yKeymaster@odiggy – You could also use:
bp_loggedin_user_avatar( 'html=false' );
(available in /bp-core/bp-core-templatetags.php)Because that will automatically call the logged in user’s avatar without using the generic bp_core_fetch_avatar() and needing additional parameters.
July 29, 2010 at 8:40 pm #87405In reply to: Installation caused avatar error that displays code
katemgilbertParticipantHere is the code on line 479 (referenced in error):
function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt ) {
July 29, 2010 at 7:53 pm #87398In reply to: Is it possible to get only the avatar-url ?
odiggyParticipantThanks for your reply!
Using bp_core_fetch_avatar( array( ‘html’ => false ) ) but still not quite working, do I need to call the logged in user id somehow along with this?
July 29, 2010 at 5:38 pm #87391In reply to: Is it possible to get only the avatar-url ?
r-a-yKeymasterUse bp_core_fetch_avatar() and pass the “html” argument as false.
Check out bp_core_fetch_avatar() @ /bp-core/bp-core-avatars.php.
July 25, 2010 at 10:43 pm #86969justbishopMemberOK, I found this in bp-core-adminbar.php. Say I wanted to get rid of the text “Blog Authors”, but only for blog ID# 12:
// **** “Blog Authors” Menu (visible when not logged in) ********
function bp_adminbar_authors_menu() {
global $bp, $current_blog, $wpdb;if ( $current_blog->blog_id == BP_ROOT_BLOG || !function_exists( ‘bp_blogs_install’ ) )
return false;$blog_prefix = $wpdb->get_blog_prefix( $current_blog->id );
$authors = $wpdb->get_results( “SELECT user_id, user_login, user_nicename, display_name, user_email, meta_value as caps FROM $wpdb->users u, $wpdb->usermeta um WHERE u.ID = um.user_id AND meta_key = ‘{$blog_prefix}capabilities’ ORDER BY um.user_id” );if ( !empty( $authors ) ) {
/* This is a blog, render a menu with links to all authors */
echo ‘- ‘;
_e(‘Blog Authors’, ‘buddypress’);
echo ‘‘;echo ‘
- ‘;
- ‘;
echo ‘user_id, $author->user_nicename, $author->user_login ) . ‘”>’;
echo bp_core_fetch_avatar( array( ‘item_id’ => $author->user_id, ’email’ => $author->user_email, ‘width’ => 15, ‘height’ => 15 ) ) ;
echo ‘ ‘ . $author->display_name . ‘‘;
echo ‘‘;
echo ‘
foreach( (array)$authors as $author ) {
$caps = maybe_unserialize( $author->caps );
if ( isset( $caps ) || isset( $caps ) ) continue;echo ‘
‘;
}
echo ‘‘;
echo ‘‘;
}
}July 23, 2010 at 11:34 pm #86824In reply to: Changing Avatar size sometimes creates Fuzzy Avatars
techguyParticipantSo, I haven’t figured all of bp_core_fetch_avatar() out, but here’s some of the types:
type=thumb
type=fullInterestingly, the code I pasted in my previous post took the thumbnail image, but displayed it the size of the full (150×150 I think). So, it was pixelated and ugly. So, I changed it to type=full and it’s a nice 150×150 image.
If anyone else can explain the rest, this seems like some good content for the codex.
July 23, 2010 at 11:21 pm #86821In reply to: Changing Avatar size sometimes creates Fuzzy Avatars
techguyParticipantI’ve been trying to get it to pull various size group avatars and haven’t had much luck. Here’s the code I’m using:
$avatar = bp_core_fetch_avatar( array( ‘item_id’ => $group->id, ‘object’ => ‘group’, ‘type’ => $type, ‘avatar_dir’ => ‘group-avatars’, ‘alt’ => $alt, ‘css_id’ => $id, ‘class’ => $class, ‘width’ => $width, ‘height’ => $height ) );Shouldn’t I just be able to pass the width and height values that I want? Am I only allowed to pass in certain width and height values? Seems like I could also pass in $type and that could give me the various sizes?
Also, this passes the full HTML for the image. Is there a way I could just get the URL of the image? I could rip it out of the HTML, but that’s kind of messy.
July 23, 2010 at 2:23 pm #86753In reply to: Changing Avatar size sometimes creates Fuzzy Avatars
Brajesh SinghParticipant@crashutah
That’s a good point. Incase we want different size for groups and members the only good way is to override the “bp_core_avatar_handle_crop” and may be in extreme case “bp_core_avatar_handle_upload” and that will give you enormous flexibility.
After overriding it, we can filter on “bp_core_fetch_avatar” and that will be all we need.July 23, 2010 at 3:28 am #86720In reply to: Changing Avatar size sometimes creates Fuzzy Avatars
- ‘;
-
AuthorSearch Results