Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_fetch_avatar'

Viewing 25 results - 201 through 225 (of 246 total)
#86824
techguy
Participant

So, I haven’t figured all of bp_core_fetch_avatar() out, but here’s some of the types:
type=thumb
type=full

Interestingly, 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.

#86821
techguy
Participant

I’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.

#86753
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.

#86720
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?

#86627
Brajesh Singh
Participant

well, 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.

#85548
vsimovic
Member

Ok, 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. :)

#84211
Justin Frydman
Participant

Well,

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’);

#83552

1.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?

#82218

In reply to: Show specific avatar

Brandon Allen
Participant

The 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.

#82037

In reply to: Show specific avatar

LPH2005
Participant

Thank 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’);

#82011

In reply to: Show specific avatar

Brandon Allen
Participant

Have 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.

#81347
Aditya Singh
Participant

Hi @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…. :D

#81290
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 mechanism

#79670
r-a-y
Keymaster

Your 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).

#76660
tinabeans
Member

Nevermind, 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. =)

#76655
tinabeans
Member

YOU 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?

Viewing 25 results - 201 through 225 (of 246 total)
Skip to toolbar