Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_fetch_avatar'

Viewing 25 results - 151 through 175 (of 258 total)
  • Author
    Search Results
  • #133729
    Paul Wong-Gibbs
    Keymaster

    WordPress’ get_avatar() should work fine. For post/page comments, I would actually suggest using get_avatar() instead of bp_core_fetch_avatar() so that your site doesn’t break if you decide to turn off or stop using BuddyPress.

    #133725
    r-a-y
    Keymaster

    Hi,

    In your comments template, you should try using the BP avatar function:
    `
    if ( function_exists( ‘bp_core_fetch_avatar’ ) ) :
    echo bp_core_fetch_avatar( array(
    ‘item_id’ => THE_USER_ID,
    ‘type’ => ‘full’,
    ‘width’ => 75,
    ‘height’ => 75
    ));
    endif;
    `

    #132635

    In reply to: Full BP Avatar URL

    shanebp
    Moderator

    Try this:
    `
    global $post; // probably don’t need this
    $author_id=$post->post_author;

    $avatar = bp_core_fetch_avatar( array( ‘item_id’ => $author_id, ‘type’ => ‘full’ ) );
    echo $avatar;
    `

    If you want to specify the height / width you can do this:
    `
    $avatar = bp_core_fetch_avatar( array( ‘item_id’ => $author_id, ‘type’ => ‘full’, ‘height’=>105,’width’=>105 ) );
    `

    #129437
    daveC87
    Member

    The custom Functions I added area as follows: (When I delete the bp-custom.php everything works fine again)

    // Setups up Type=Full avatar pics for BP-post author
    function bp_custompost_author_avatar() {
    global $post;

    if ( function_exists(‘bp_core_fetch_avatar’) ) {
    echo apply_filters( ‘bp_post_author_avatar’, bp_core_fetch_avatar( array( ‘item_id’ => $post->post_author, ‘type’ => ‘full’, ‘width’ => ’70’, ‘height’ => ’70’ ) ) );
    } else if ( function_exists(‘get_avatar’) ) {
    get_avatar();
    }
    }

    // Changes order for member profile menu items
    function bbg_change_profile_tab_order() {
    global $bp;

    $bp->bp_nav = 20;
    $bp->bp_nav = 30;
    $bp->bp_nav = 40;
    $bp->bp_nav = 50;
    $bp->bp_nav = 60;
    $bp->bp_nav = 70;
    $bp->bp_nav = 80;

    $bp->bp_nav = false;
    $bp->bp_nav = false;

    }
    add_action( ‘bp_setup_nav’, ‘bbg_change_profile_tab_order’, 999 );*/

    // Setup the navigation
    // Props to http://wordpress.stackexchange.com/questions/16223/add-buddypress-profile-menu-item for helping me figure this out
    // and http://themekraft.com/customize-profile-and-group-menus-in-buddypress/
    function my_setup_nav() {
    global $bp;

    bp_core_new_nav_item( array(
    ‘name’ => __( ‘my adventure list’, ‘buddypress’ ),
    ‘slug’ => ‘my-adventure-list’,
    ‘position’ => 10,
    ‘screen_function’ => ‘my_adventure_list_link’,
    ‘show_for_displayed_user’ => true,
    ‘default_subnav_slug’ => ‘my-adventure-list’,
    ‘item_css_id’ => ‘my-adventure-list’
    ) );
    }

    add_action( ‘bp_setup_nav’, ‘my_setup_nav’, 1000 );

    function my_adventure_list_title() {
    echo ‘My Adventure List’;
    }

    function my_adventure_list_content() {
    ?>


    <?php
    }

    function my_adventure_list_link () {
    add_action( ‘bp_template_title’, ‘my_adventure_list_title’ );
    add_action( ‘bp_template_content’, ‘my_adventure_list_content’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/my-adventure-list’ ) );
    }

    ?>

    #129389
    dgodot
    Member

    Thanks, mercime, but I’m not sure I understand. I’m not trying to change the size of avatars in the comments section, but rather in the sidebar for a multi-user buddypress site.

    I see that in your code you’re using bp_core_fetch_avatar(). That function seems to produce the same output as get_avatar() for me — which is the avatar thumbnail scaled to whatever size I specify. Am I missing something?

    #129238
    r-a-y
    Keymaster

    That’s old, old code.

    Use something like this to change the default group avatar:

    `
    // turn gravatars off
    add_filter( ‘bp_core_fetch_avatar_no_grav’, ‘__return_true’ );

    // change the default group avatar
    function ray_change_group_avatar_default() {
    return ‘URL TO GROUP DEFAULT AVATAR’;
    }
    add_filter( ‘bp_core_default_avatar_group’, ‘ray_change_group_avatar_default’ );`

    Untested! This only works with gravatars turned off.

    #127926

    In reply to: Conditional Avatars

    r-a-y
    Keymaster

    Since you’re using:
    `add_filter( ‘bp_core_fetch_avatar_no_grav’, ‘__return_true’ );`

    You can also define your mystery man image with:
    http://pastebin.com/AST92STz

    For LINKTOYOURIMAGE.gif, try making it a transparent GIF. That’s probably the best you can do at the moment.

    Also, a ticket was just brought up to add CSS classes to avatars:
    https://buddypress.trac.wordpress.org/ticket/3922

    Keep an eye on that one.

    #127885

    In reply to: Conditional Avatars

    InHouse
    Member

    Is there a filter I can add to bp-customs.php that will skip the mystery man?
    `add_filter( ‘bp_core_default_avatar_no_grav’, ‘__return_true’ );`

    I’m already using the one that skips the Gravatar.
    `add_filter( ‘bp_core_fetch_avatar_no_grav’, ‘__return_true’ );`

    Any ideas? My last resort would be to hack bp-core-avatars.php but I don’t want to do anything preventing upgrading of course.

    #127778
    drummergirl
    Participant

    Found what I needed…

    $avatar = bp_core_fetch_avatar( array( ‘item_id’ => ‘4’, ‘object’ => ‘group’, ‘type’ => ‘full’, ‘avatar_dir’ => ‘group-avatars’, ‘alt’ => $alt, ‘css_id’ => $id, ‘class’ => $class, ‘width’ => $width, ‘height’ => $height ) );

    Towfiq I.
    Member

    Never mind, got it. Had to write a custom function:

    `function bp_custompost_author_avatar() {
    global $post;

    if ( function_exists(‘bp_core_fetch_avatar’) ) {
    echo apply_filters( ‘bp_post_author_avatar’, bp_core_fetch_avatar( array( ‘item_id’ => $post->post_author, ‘type’ => ‘full’ ) ) );
    } else if ( function_exists(‘get_avatar’) ) {
    get_avatar();
    }
    }
    `

    modemlooper
    Moderator

    If it’s a members page use bp_core_fetch_avatar()

    #125126

    In reply to: User Avatar Hook

    Paul Wong-Gibbs
    Keymaster

    Take a look at BP’s bp_core_fetch_avatar_filter() function.

    #125115
    r-a-y
    Keymaster

    You shouldn’t use the members loop if you don’t need it.

    A more efficient call is using bp_core_fetch_avatar() and setting the parameters there. (Make sure you use a function_exists() call if you use this approach.)

    You can alternatively filter get_avatar() as well using bp_core_fetch_avatar() as well.

    julien760
    Member

    hello,

    I try to do the same thing. I want to display a specific picture following the gender of the members.

    I use add_filter and the picture of the profil is the good one but all others pictures from sidebar, for example, are the same…

    Have you finally find a solution for this issue ?

    Thanks in advance,

    My test 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() .’/images/bp_default_avatar.gif’;
    if( $image && strpos( $image, “gravatar.com” ) ){
    if ( bp_get_profile_field_data( ‘field=Gender’ ) == ‘Female’ ) {
    $default = get_stylesheet_directory_uri() .’/images/def_f_avatar.gif’;
    return ‘female‘;
    }
    if ( bp_get_profile_field_data( ‘field=Gender’ ) == ‘Male’ ) {
    $default = get_stylesheet_directory_uri() .’/images/def_m_avatar.gif’;
    return ‘male‘;
    }
    else {
    return $image;
    }
    } else {
    return $image;
    }
    }
    add_filter(‘bp_core_fetch_avatar’, ‘bp_remove_gravatar’, 1, 9 );

    #123242
    logixz
    Member

    @modemlooper understood, I was thinking that since that SQL queries pulls the userid I could somehow tie in bp_core_fetch_avatar into the equation?

    #119714
    modemlooper
    Moderator

    Found the avatar filters but not sure how to change it to display the associated group avatar.

    $object = apply_filters( ‘bp_get_activity_avatar_object_’ . $current_activity_item->component, ‘user’ );

    return apply_filters( ‘bp_get_activity_avatar’, bp_core_fetch_avatar( array( ‘item_id’ => $item_id, ‘object’ => $object, ‘type’ => $type, ‘alt’ => $alt, ‘class’ => $class, ‘width’ => $width, ‘height’ => $height, ’email’ => $email ) ) );

    EDIT: seems just changing user to groups will get the image.

    #119169
    dyerrington
    Member

    Solution: Getting the URL with bp_core_fetch_avatar() and using the option ‘html’ => false to get group images by URL rather then a whole image tag.

    IE:
    `
    $avatar_options = array ( ‘item_id’ => ‘1’, ‘object’ => ‘group’, ‘type’ => ‘full’, ‘avatar_dir’ => ‘group-avatars’, ‘alt’ => ‘Group avatar’, ‘css_id’ => 1234, ‘class’ => ‘avatar’, ‘width’ => 50, ‘height’ => 50, ‘html’ => false );

    $result = bp_core_fetch_avatar($avatar_options);
    `

    Looking at this particular code makes me nervous about performance. Is it necessary to read from the database and the filesystem to get this type of resource? I sure hope there’s some caching going on somewhere.

    #119149
    dyerrington
    Member

    Alright, drilling down a bit further, in bp-groups/bp-grouptemplatetags.php, around line 279, there’s our bp_get_group_avatar() method.

    `
    function bp_get_group_avatar( $args = ” ) {
    global $bp, $groups_template;

    $defaults = array(
    ‘type’ => ‘full’,
    ‘width’ => false,
    ‘height’ => false,
    ‘class’ => ‘avatar’,
    ‘id’ => false,
    ‘alt’ => __( ‘Group avatar’, ‘buddypress’ )
    );

    $r = wp_parse_args( $args, $defaults );

    extract( $r, EXTR_SKIP );
    var_dump(‘buddypress group_avatar_call’, bp_core_fetch_avatar( array( ‘item_id’ => $groups_template->group->id, ‘object’ => ‘group’, ‘type’ => $type, ‘avatar_dir’ => ‘group-avatars’, ‘alt’ => $alt, ‘css_id’ => $id, ‘class’ => $class, ‘width’ => $width, ‘height’ => $height )) );
    /* Fetch the avatar from the folder, if not provide backwards compat. */
    if ( !$avatar = bp_core_fetch_avatar( array( ‘item_id’ => $groups_template->group->id, ‘object’ => ‘group’, ‘type’ => $type, ‘avatar_dir’ => ‘group-avatars’, ‘alt’ => $alt, ‘css_id’ => $id, ‘class’ => $class, ‘width’ => $width, ‘height’ => $height ) ) )
    $avatar = ‘group->avatar_thumb ) . ‘” class=”avatar” alt=”‘ . esc_attr( $groups_template->group->name ) . ‘” />’;

    return apply_filters( ‘bp_get_group_avatar’, $avatar );
    }
    `

    So I’ve var dumped the parameters that are used for bp_core_fetch_avatar() when it’s called from the default group landing page, then var_export($args, true) and copied that output directly to my own code and surprisingly, I get the same result as before, a blank img tag. So, this leads me to believe that this method is not meant to be used in the way I am using it.

    As I find a better solution, I will follow up in case this is useful to someone else.

    #118867
    gordyr
    Member
    Code:
    <?php $member_id = bp_core_get_userid( ‘{{comment_by}}’ ) ?>

    <a href="<?php echo bp_core_get_user_domain( $member_id ) ?>" title="<?php echo bp_core_get_user_displayname( $member ) ?>"><?php echo bp_core_fetch_avatar ( array( ‘item_id’ => $member_id, ‘type’ => ‘thumb’ ) ) ?></a>

    #117959
    rbbp22
    Member

    Me again.

    I would like to edit the above posts, but this forum is not allowing me to do so. Clicking “Edit” gets me to “page not found.”

    Anyway. I take back that it’s necessary to add a hidden field.

    I think the change that is needed is
    the last line in the function
    bp_get_signup_avatar_dir_value()
    in bp-core-templatetags.php

    change
    return apply_filters( ‘bp_get_signup_avatar_dir_value’, $bp->signup->avatar_dir );
    to
    return apply_filters( ‘bp_get_signup_avatar_dir_value’, $signup_avatar_dir );

    However, I note that if the registrant uploads more than one avatar (i.e. replaces their avatar) during the registration process the avatar displayed will be the first one uploaded.

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

    This is called in the function bp_get_signup_avatar in bp-core-templatetags.php.

    The problem is that if the user uploads more than one avatar the old ones are not deleted.

    bp_core_fetch_avatar() seems to get the first on uploaded and this is the one that is displayed when the register.php template runs even if newer avatars have been uploaded during the registration process.

    @mercime
    Participant
    ramprakav
    Member

    there is a problem in that avatar so i cant upload my avatar

    sidjags
    Member

    hello everyone.. found a solution to this.. so thought i’d share it here too.. (i’m posting this in all the different threads out there about the same topic)

    If you want a custom set of pics to replace the default buddypress avatars and be assigned by random to members… here goes:

    https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/custom-set-of-avatar-pics/#post-101775

    sid

    sidjags
    Member

    any progress? would love to see whats been done and test it out to see if we can use it… really looking forward to this.

    David Bisset
    Participant

    This is cool, i’ve been monitoring this off and on – glad to see you come through! Happy to test this one out.

Viewing 25 results - 151 through 175 (of 258 total)
Skip to toolbar