Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_fetch_avatar'

Viewing 25 results - 226 through 250 (of 310 total)
  • Author
    Search Results
  • #109684
    r-a-y
    Keymaster

    Check out the “bp_core_mysteryman_src” and “bp_core_fetch_avatar” filters located in /bp-core/bp-core-avatars.php.

    This article details a little bit of how to do it:
    http://wpmu.org/how-to-add-a-custom-default-avatar-for-buddypress-members-and-groups/

    Lawrence
    Participant

    @Reezo, @Dimensionmedia:

    Thanks guys… sorry for taking such a long time to update on this. Ended up having to work on some other projects. I’ve managed to get the custom avatar generator to function okay now, and have a live project that uses it (http://school.ocdaction.org.uk/), but I need to tidy up the code a little. At the moment I’m having to plug the wordpress avatar function (get_avatar) and use that for my rendering duties. What I’d like to happen is for the bp dev team to make their bp_core_fetch_avatar pluggable, as it doesnt really have much scope for extending in its current state. Maybe I’m wrong, but if someone has more knowledge of how to alter bp_core_fetch_avatar for my needs then that would be awesome. I did think of filtering, but one aspect of bp_core_fetch_avatar I don’t particulary see the need of is that it pushes the final img url through http://www.gravatar.com, which in my opinion is a wasted resource, as this plugin would only read directly off the parts folder when it generates an avatar, and then loads from a cache dir.

    Welcome any thoughts on this.

    #109018
    amittrehan
    Member

    thank you mercime for replying. its the ajax.php that is the problem. this is the error that i get

    ‘Warning: Cannot modify header information – headers already sent by (output started at /…./public_html/chill/wp-content/plugins/buddypress/bp-themes/bp-default/_inc/ajax.php:553) in /…./public_html/chill/wp-content/plugins/buddypress/bp-messages.php on line 556’. i have already checked the above link.

    line 553 in ajax.php is this below line code:

    ‘echo bp_core_fetch_avatar(array(‘item_id’ =>$user_id,’type’=>’thumb’,’width’=>15,’height’ =>15)).’ ’.bp_core_get_user_displayname($user_id).’(‘.$username.’)’;
    } ‘

    regards
    amit

    #20970
    amittrehan
    Member

    i have searched on google to solve this problem and done almost everything but cannot get rid of this error. i am new to php and do not know what is going wrong. the last two lines of the code mentioned below in the ajax.php file which is responsible for the error.

    ‘ if ( $friends ) {
    foreach ( (array)$friends as $user_id ) {
    $ud = get_userdata($user_id);
    $username = $ud->user_login;
    echo bp_core_fetch_avatar(array(‘item_id’ =>$user_id,’type’=>’thumb’,’width’=>15,’height’ =>15)).’ ‘.bp_core_get_user_displayname($user_id).'(‘.$username.’)’;
    } ‘

    i would be grateful if someone can help me and point out what is wrong with the code.

    regards
    amit

    Reezo
    Participant

    @grimbog: This is interesting. Hope to hear good news soon.

    #107799

    In reply to: Recent Post plugin

    r-a-y
    Keymaster

    @rogerwhitson – In response to this, you add the bp_core_fetch_avatar() function in your recent post loop.

    It would look something like this:

    ` $user_id ) ); ?>`

    I’m guessing that the recent posts loop is a widget; you’d have to add the code above into the widget’s code somewhere.

    You would also have to pass the $user_id properly in the loop.

    #107606

    hi
    here is the solution for getting the avatar image url
    bp_core_fetch_avatar(array(‘item_id’ => $other_user, ‘type’ => ‘thumb’, ‘width’ => 32, ‘height’ => 32, ‘class’ => ‘friend-avatar’,’html’=>false));

    html = false

    #107109
    Virtuali
    Participant

    Wait… do you mean a subnav? Like for instance, under profile, the subtabs are “Edit Profile, and Change Cignature?”

    Could be done, wrap the bp_core_new_subnav_item call in a function which is hooked on xprofile_setup_nav action;

    `/* Add the subnav items */
    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;
    }`

    There ya go, 2 in one! ;)

    #106871
    r-a-y
    Keymaster

    That’s the WP version of grabbing the avatar.

    You can also try the BuddyPress way:
    `echo bp_core_fetch_avatar( array( ‘item_id’ => $id, ‘width’ => $width, ‘height’ => $height ) );`

    A list of full parameters can be found by looking at the source:
    https://trac.buddypress.org/browser/tags/1.2.8/bp-core/bp-core-avatars.php#L50

    Cam
    Participant

    @boonebgorges

    I am a complete newbie when it comes to this. I tried to utilize the funciton you created above and it results in an error: Unexpected return.

    I imagine I am missing something obvious but here is my code:
    `function my_blog_avatar_1( $old_avatar ) {
    bp_core_fetch_avatar( array( ‘item_id’ => ‘1’, ‘type’ => $type, ‘alt’ => $alt, ‘width’ => $width, ‘height’ => $height, ‘class’ => $class ) ) // Do some stuff to get the avatar you want, then
    return $new_avatar;
    }
    add_filter( ‘bp_get_blog_avatar_1?, ‘my_blog_avatar_1’ );`

    Thanks in advance for your help.

    #106174

    In reply to: Recent Post plugin

    r-a-y
    Keymaster

    Pass the user id as the “item_id” parameter in bp_core_fetch_avatar().

    This function is located in /bp-core/bp-core-avatars.php.

    #20071
    G2Gmin
    Participant

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

    David Bisset
    Participant

    @grimbog

    Was there any progress on this? I was interested in the same thing, whether if it’s code or an actual plugin.

    Thanks!

    #101581
    Boone Gorges
    Keymaster

    You will have te create a custom function, either in your theme’s functions.php or in plugins/bp-custom.php, that filters the output of that function and replaces it with the avatar of your choice. Eg, if your blog_id is 5,
    ‘function my_blog_avatar( $old_avatar ) {
    // Do some stuff to get the avatar you want, then
    return $new_avatar;
    }
    add_filter( ‘bp_get_blog_avatar_5’, ‘my_blog_avatar’ );`

    The ‘do some stuff’ part will depend highly on your setup. If by ‘the associated group’ you mean that you are using bp-groupblog, then you will likely have to do some direct queries of the groupmeta database table to find the group that is associated with a particular blog (I don’t think that the plugin stores that info in a place that is easily accessible by blog_id). Then you will use some permutation of bp_core_fetch_avatar() to pull up the avatar for that group_id.

    Good luck!

    #101490
    scabadaska
    Member

    Hi @BuddyPresser,

    I would like to add to Javier’s @arques post above. His method does work but it’s missing the initial sign-up screen where gravatar is being pulled. I also rewrote his path a bit. This should do the trick for killing all Gravatar calls. If someone has more time than I it would be great to have this in plugin form. Here is the code:

    `
    function bp_remove_gravatar ($image, $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir) {

    $default = get_stylesheet_directory_uri() .’/_inc/images/bp_default_avatar.jpg’;

    if( $image && strpos( $image, “gravatar.com” ) ){

    return ‘avatar‘;
    } 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 = get_stylesheet_directory_uri() .’/_inc/images/bp_default_avatar.jpg’;
    return “{$alt}“;
    }

    add_filter(‘get_avatar’, ‘remove_gravatar’, 1, 5);

    function bp_remove_signup_gravatar ($image) {

    $default = get_stylesheet_directory_uri() .’/_inc/images/bp_default_avatar.jpg’;

    if( $image && strpos( $image, “gravatar.com” ) ){

    return ‘avatar‘;
    } else {
    return $image;
    }

    }
    add_filter(‘bp_get_signup_avatar’, ‘bp_remove_signup_gravatar’, 1, 1 );
    `

    The image that I am referencing doesn’t have to be a JPG. The size is 150×150. You may have to adjust the file name and/or path to your liking.

    Thanks @arques for the initial code!

    #98097
    r-a-y
    Keymaster

    If you need to stay on BP 1.2.4, you could probably just copy the part of the bp_core_fetch_avatar() function that adds support for the ‘html’ parameter… but I’d strongly suggest upgrading when you have the chance.

    See the codex article on upgrading:
    https://codex.buddypress.org/buddypress-site-administration/upgrading-buddypress/

    #98083
    r-a-y
    Keymaster

    Try this:
    `bp_core_fetch_avatar( ‘html=false’ );`

    Be sure to check out the full parameters for the function in bp-core-avatars.php.

    #16595
    powers1
    Member

    How can I retrieve the URL to a user or group’s avatar/gravatar *without* the `IMG` HTML tag? For our site layout we’re looking to use the avatar as a background image of a DIV – so we need just the URL, none of the `IMG` stuff. For instance, I’m using the `bp_group_avatar` function to return an `IMG` tag and using a regex to match the `SRC` attribute – but this is ugly and hackish. Is there a better way?

    Using Buddypress 1.2.4.1

    **Edit**

    Looking at the `bp_core_fetch_avatar` – I’m seeing hard-coded `IMG` tag – so I’m thinking no, this isn’t possible :(

    #97733
    Javier Arques
    Participant

    Hi @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 ‘avatar‘;
    }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 “{$alt}“;
    }

    add_filter(‘get_avatar’, ‘remove_gravatar’, 1, 5);
    `

    It worked for me

    #97121
    Boone Gorges
    Keymaster

    Cool, 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 );`

    #97104
    mistercyril
    Participant

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

    #96997
    Boone Gorges
    Keymaster

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

    Lawrence
    Participant

    Hey 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.jpg

    Lawrence
    Participant

    Hey guys, I’m working on a plugin that is an adaptation of ravatar (which was built for for WordPress 2.5). I realise its been out of development for a while, but I’ve done some code changes and have it working on the latest 3.x WordPress – I wanted to use my own random (wavatar) type system where I design different head graphics and have them alternate colour/background etc. as I grew tired of the wavetar effect and wanted my own graphic.

    Wondering if people are interested in this as a public release?

    UPDATE 04/02/2013: Firstly just want to apologise for the delay – ended up getting side-tracked with a large site/project. However I just thought I’d mention that I will endeavour to get this up and will create a new topic when this happens. All the code is there on my development machine… I just wish I had more time to add in a proper backend for it!

    caplain
    Member

    Thanks. 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;

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