Search Results for 'bp_core_fetch_avatar'
-
AuthorSearch Results
-
August 21, 2010 at 7:15 am #89890
warut
Participant@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 Coathup
Participant@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-y
KeymasterTo 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 ?
techguy
Participant@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-y
Keymaster@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
katemgilbert
ParticipantHere 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 ?
odiggy
ParticipantThanks 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-y
KeymasterUse 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 #86969justbishop
MemberOK, 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
techguy
ParticipantSo, 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
techguy
ParticipantI’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 Singh
Participant@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
techguy
Participant@sbrajesh It seems like the group avatar’s use this same code. How would you call the bp_core_fetch_avatar of varying sizes for groups by group id?
July 22, 2010 at 2:26 pm #86627In reply to: Changing Avatar size sometimes creates Fuzzy Avatars
Brajesh Singh
Participantwell, The very first thing is
1. define the 2 size(bp allows only 3 sizes of avatar at this moment) using the constants BP_AVATAR_(THUMB/FULL/ORIGINAL_MAX)_HEIGHT and BP_AVATAR_(THUMB/FULL/ORIGINAL_MAX)_WIDTH if the original avatar sizes(50×50,150×150,450×450) does not fit your requirement.Then use bp_core_fetch_avatar, it supports the width,height property and thumb type
You can fetch an avatar of different size using different width/height value but again, It will not crop, it will constrain the avar using the width/height property in the img tag. so i don’t think it will be of much use .But if you want only 2 sizes of avatar, as you mentioned above, define one as Thumb,other as full and fetch thumb using “type=thumb” and the other using “type=anything other than thumb” in bp_core_fetch_avatar and it will work.
July 14, 2010 at 10:46 am #85548vsimovic
MemberOk, i’ve managed to do it with:
global $bp;
bp_core_fetch_avatar( array( ‘item_id’ => $id, ‘type’ => ‘full’, ‘width’ => ’75’, ‘height’ => ’75’, ‘html’ => ‘false’ ) )If somebody needs the same thing he can try this lines, maybe it will help.
July 4, 2010 at 2:41 pm #84211In reply to: [Resolved] Customizing bp_get_displayed_user_nav()
Justin Frydman
ParticipantWell,
I tried remove_action on the function I found that I want to customize, but it doesn’t work apparently because bp-custom.php is being loaded before bp-friends. I tried this in my theme’s functions.php as well, but it still does not work. What am I doing wrong?
/***
* Create custom functions for buddypress so updates do not override customizations
*/function my_friends_setup_nav() {
global $bp;/* Add ‘Friends’ to the main navigation */
bp_core_new_nav_item( array( ‘name’ => sprintf( __( ‘Friends (%d)2222′, ‘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’ => __( ‘Requests’, ‘buddypress’ ), ‘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( ‘my_friends_setup_nav’);
}
remove_action( ‘bp_setup_nav’, ‘friends_setup_nav’);
add_action( ‘bp_setup_nav’, ‘my_friends_setup_nav’);June 30, 2010 at 3:18 am #83552In reply to: Single sitewide avatar per user?
John James Jacoby
Keymaster1.2.5 has an almost totally rewritten bp_core_fetch_avatar function that should fix these issues. Can you confirm that all files are up to date and try again?
June 22, 2010 at 2:37 am #82218In reply to: Show specific avatar
Brandon Allen
ParticipantThe user_id argument doesn’t exist because there is no user_id argument. The argument that accepts a user id is the item_id argument as I stated above. Try this:
echo bp_core_fetch_avatar( array( ‘width’ => 30, ‘height’ => 30, ‘item_id’ => 1 ) );
If all you need is the thumbnail, then you don’t need the ‘type’ argument, as it defaults to thumbnail.
June 20, 2010 at 3:44 pm #82037In reply to: Show specific avatar
LPH2005
ParticipantThank you. Since I’m not good with php, my interpretation doesn’t seem to work. This is the echo statement to get the avatar to show, however, I’m not sure that the user_id argument works. The area for this statement is blank.
echo bp_core_fetch_avatar(‘type=thumb&width=30&height=30&user_id=1’);
June 20, 2010 at 6:41 am #82011In reply to: Show specific avatar
Brandon Allen
ParticipantHave a look at bp_core_fetch_avatar(). It accepts a number of arguments you’ll want to explore for your use case. The most important being $item_id, which in your case would be your user id number and that user id of your teacher.
June 12, 2010 at 3:09 am #81347In reply to: Changing the way group avatars are fetched
Aditya Singh
ParticipantHi @r-a-y
Its again you to my rescue!
Thanks. Yeah I had looked up on Bp_core_fetch_avatar function in bp-core-avatars.php file, and that it has a parameter ‘object’ => with the comment that we can use it if we are using filter.Its just that I could not figure out how to do it. Tried few things unsuccessfully.
Would it be possible for you to guide me here. Lets say I am uploading my avatars in the standard file-size in some folder in the format “grpavtr_(group_id).png”, then how do I do it…. Have been stuck with this problem (and one more) for a week now…

I am sure I would go out and have a beer once I’m done with this….
June 11, 2010 at 2:28 pm #81290In reply to: Custom avatars arent showed on single blogs in WPMU
Anna Ladoshkina
Participant@justbishop I also use the subdirectories – so filters should be OK in this case
but probably you have some custom avatar upload path or constant BP_ROOT_BLOG is not defined in your installation?
another possible reason – the function that fetch avatars for members blogs does not use bp_core_fetch_avatar() but some other mechanismMay 25, 2010 at 11:01 pm #79670In reply to: Querying specific groups based on parameters
r-a-y
KeymasterYour pastie link doesn’t work.
This is working for me:
$myslug = 'my-test-group';
if ( bp_has_groups('type=single-group&slug='.$myslug) )For some reason, you have to add the type as “single-group” as well.
If you’re just trying to get the group avatar of one group… just use bp_group_avatar() (view the params in bp-groups-templatetags.php) or bp_core_fetch_avatar() (view params in bp-core-avatars.php).
May 4, 2010 at 9:37 pm #76660tinabeans
MemberNevermind, I googled for that function and found the SVN repo where that function is defined: http://bp-dev.org/phpxref/nav.html?_functions/index.html
The params it takes are:
$defaults = array(
‘item_id’ => false,
‘object’ => ‘user’, // user OR group OR blog OR custom type (if you use filters)
‘type’ => ‘thumb’,
‘avatar_dir’ => ‘avatars’,
‘width’ => false,
‘height’ => false,
‘class’ => ‘avatar’,
‘id’ => false,
‘alt’ => __( ‘Avatar Image’, ‘buddypress’ ),
);… and the params can be fed into bp_core_fetch_avatar() in the form of “name=value&name=value” pairs as a string.
Hope this helps someone else who is having the same issue.
May 4, 2010 at 9:32 pm #76655tinabeans
MemberYOU ARE AMAZING! You know, you just redeemed my whole afternoon of work. Hooray
I owe you a beer for that one!Well… here’s the postscript. It all comes back to one thing I’ve been frustrated with: why is there no good documentation on BP or BBpress template tags? I had to search the code repo to find a hint that bp_core_get_avatar() was deprecated in favor of bp_core_fetch_avatar(), and after that still didn’t know that I had to put “item_id=” before the ID in the argument string. Not sure how I would have figured that one out on my own, given my apparent lack of PHP reading skills.
If someone knows a secret source of well-documented template tags, do let me know. All I’ve found so far is https://codex.buddypress.org/developer-discussions/buddypress-template-tags/ for Buddypress (which doesn’t even have bp_core_fetch_avatar() listed). Bummer.
Okay, I do have one last question for you: what other params does bp_core_fetch_avatar() take, and how can I find out? for instance, can I specify a different size of avatar?
- ‘;
-
AuthorSearch Results