Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_fetch_avatar'

Viewing 25 results - 226 through 250 (of 258 total)
  • Author
    Search Results
  • #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.

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

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

    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?

    r-a-y
    Keymaster

    @tinabeans – just tested the following snippet:

    echo bp_core_fetch_avatar( 'item_id='.get_post_author_id() );

    This is working for me on a deep-integrated external bbPress install. Let me know if this works for you.

    #72050

    In reply to: WP-FB connect profile.

    joshmac
    Participant

    Ok, this is what I’ve come up with so far in order to get the user’s facebook profile pic. However, they disappear when you log in. If anyone is willing to add to this to give it the finishing touch it needs or can tell me what to add that would be great.

    add_action('wpfb_login', 'bp_jfb_get_avatar');

    function bp_jfb_get_avatar($avatar, $id_or_email='') {
    global $comment; $id_or_email;

    if(is_object($comment)) {
    $user_id = $comment->user_id;
    }

    if (is_object($id_or_email)) {
    $user_id = $id_or_email->user_id;
    }

    if (is_array($id_or_email)) {
    if ($id_or_email['object']=='user') {
    $user_id = $id_or_email['item_id'];
    }
    }

    if (get_usermeta($user_id, 'facebook_uid')) {
    $user_info = get_userdata($user_id);
    $jfb_suffix = '';

    if ( $id_or_email['width'] ) {
    $jfb_size = $id_or_email['width'];
    if( $jfb_size < 32 ) {
    $jfb_suffix = 'm';
    } else if ( $jfb_suffix < 64 ) {
    $jfb_suffix = 'n';
    } else {
    $jfb_suffix = 'b';
    }
    } else if ( 'full' == $id_or_email['type'] ) {
    $jfb_size = BP_AVATAR_FULL_WIDTH;
    $jfb_suffix = 'b';
    } else if ( 'thumb' == $id_or_email['type'] ) {
    $jfb_size = BP_AVATAR_THUMB_WIDTH;
    $jfb_suffix = 'n';
    }
    $avatar = '<fb:profile-pic uid="'.$user_info->facebook_uid.'" facebook-logo="true" size="'.$jfb_size.'" width="'.$jfb_size.'" linked="true" class="avatar"></fb:profile-pic>';
    return $avatar;

    } else {
    return $avatar;
    }

    }
    add_filter( 'bp_core_fetch_avatar', 'bp_jfb_get_avatar',10,4);

    This code should go in a bp-custom.php file and uploaded to the mu-plugins directory.

    #71717
    rich! @ etiviti
    Participant

    what redirect chain is that?

    only thing i see in

    function bp_core_fetch_avatar( $args = '' ) {

    which might slow down the process is checking for

    if ( file_exists( $avatar_folder_dir ) ) {

    if you have disabled avatar uploads for members.

    #71615
    jivany
    Participant

    What if you removed the existing bp_core_fetch_avatar_filter from get_avatar and then created your own copy that passed ‘no_grav’=>true into the bp_core_fetch_avatar function?

    I think this should kill the attempt to use Gravatar to fetch an avatar. I’m assuming that bp_core_fetch_avatar isn’t being called directly anywhere. If you do find anywhere that does, it should probably have a ticket raised against it.

    #71610
    oberstet
    Participant

    thanks for helping.

    @r-a-y

    i’ve already hacked bp_core_fetch_avatar() as described in https://buddypress.org/forums/topic/how-to-disable-gravatar-completely

    however, a quick grep for gravatar.com over all wp/bb reveals more places. i am a total wwp/bb/php idiot and have no aspirations to become even mildy involved with the codebase. i was looking for a on-place “checkbox solution”.

    @DJPaul

    ah, ok;) it’s ok to have such commerically motivated “defaults” … in the end its a pretty impressing piece of tool and its nice to share anyway. on the other hand, it would be nice to have a big “this is a private site” switch which turns off this, and other things (like the dashboard fetching stuff from outside … i “disabled” that one using a firewall rule;)

    #71606
    r-a-y
    Keymaster

    This isn’t hard at all.

    Apply a filter to:

    bp_gravatar_url

    Return a url to a default image.

    [EDIT]

    Just noticed that bp_gravatar_url only changes the domain… the params are still added at the end of the URL.

    Might try applying a filter to:

    bp_core_fetch_avatar

    Write a function to see if “gravatar.com” exists in the image URL, if so, return a default image.

    #70945

    In reply to: error codes with 1.2

    kiwipearls
    Participant

    I too am getting this error, not on my main blog, but just one of my user blogs. I thought it could have been the theme, but my personal blog uses the same theme as this user.

    I have ust moved my site over to a new domain, everthing is working great on the main blog. but on my user blogs I am running into a problem with comments – they have an error…

    Warning: Missing argument 5 for bp_core_fetch_avatar_filter() in senilityguild.com/public_html/wp-content/plugins/buddypress/bp-core/bp-core-avatars.php on line 345

    The user blog with comment post is: http://senilityguild.com/ledsoul/2010/03/14/new-senilily-banner/

    And my personal blog is(using same theme): http://senilityguild.com/kiwipearls/2010/03/maggotyanne/

    And the main blog is http://senilityguild.com

    So what has broken on this users theme? And what can I do to fix this? Wondering if I should just import that users db over again? (as i had to import the 3 user blogs separately to the main blog, as I think the main blog was a little bit corrupted as the old site had lots of problems)

    Using most recent Buddypress 1.2.3 ?(get my numbers mixed up)and MU 2.9.2

    #70322
    3sixty
    Participant

    re: forum index

    etiviti (rich!), I spiffed up the forum index by adding Group/Forum avatars beside the forum title/description (see code below)

    Question: can you think of an easy way to include a link to the last active post, say, in a final column? I looked at the code last night didn’t get that far.

    Add Avatar to BP Forum Extras – Forum Index

    Under:

    <td class=”num td-title”>

    Add:

    <div class=”item-avatar”>

    <?php $width=50;$height=50;$type=’thumb’; echo bp_core_fetch_avatar( array( ‘item_id’ => $listing->id, ‘object’ => ‘group’, ‘type’ => $type, ‘avatar_dir’ => ‘group-avatars’, ‘width’ => $width, ‘height’ => $height ) ) ?>

    </div>

    #64421
    r-a-y
    Keymaster

    Look into the bp_core_fetch_avatar() function in bp-core/bp-core-avatars.php.

    Sounds good to me. Not sure if there’s a better way performance-wise.

    #60421
    Mike Pratt
    Participant

    @djpaul don’t worry, I don’t think he’ll do it :-)

    @bowe Here is an example of what’s in 1.2 right now (@Andy – is this what you were talking about?)

    from single.php

    <div class=”author-box”>

    <?php echo get_avatar( get_the_author_email(), ’50’ ); ?>

    <p><?php printf( __( ‘by %s’, ‘buddypress’ ), bp_core_get_userlink( $post->post_author ) ) ?></p>

    </div>

    So in the same code block we get the WP based avatar while getting the BP based Name. Hmm. Not sure why but I am going to use either bp_loggedin_user_avatar() or bp_member_avatar() instead, or possibly bp_core_fetch_avatar() feeding in the id via bp_core_fetch_avatar($post->post_author) but I am just flying by the seat of my pants and have not tried it yet.

    I do know this. We know who the post author is. We know he has a username. That username is the same in WP or BP, so we can get his BP avatar and other info via that route. The rest is theming.

    #60217
    Brajesh Singh
    Participant

    The code for fetching avatar resides in buddypress/bp-core/bp-core-avatar.php

    checkout this function there

    bp_core_fetch_avatar

    There are several filters there and you can use those filters to manipulate the things better.

    #59372

    In reply to: Blog post avatar help

    Brajesh Singh
    Participant

    replace that line with this one

    <?php
    global $post;
    echo bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb', 'width' => 50, 'height' => 50));
    ?>

    Hope it helps

    #58950
    Brajesh Singh
    Participant

    The reason is bp_get_group_avatar_thumb() assumes you are inside group loop and simply ignores the $group,which you passed.

    A possible solution will use this method instead.

    //code edited from here

    Edit:checked my template, It seems ,It does not work. Instead use

    bp_core_fetch_avatar( array( 'item_id' =>YOURGROUPID, 'object' => 'group', 'type' => 'thumb', 'width' => 64 ,'height' => 64 ) )

    Hope It helps.

Viewing 25 results - 226 through 250 (of 258 total)
Skip to toolbar