Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_fetch_avatar'

Viewing 25 results - 151 through 175 (of 246 total)
  • Author
    Search Results
  • #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.

    Lawrence
    Participant

    @djpaul: Thanks Paul, I would really appreciate any thoughts and feedback when its out, as I can imagine the coding will be a little hazy in places. Should be fairly easy to understand though.

    Paul Wong-Gibbs
    Keymaster

    Hey, looks like a novel approach — I’ll have a play when you get the plugin out

    Lawrence
    Participant

    Good news all… I’ve finally got this working as intended, and I’m currently in the process of packing it all together in to a plugin for release to the community over the next few days. Just creating a small webpage where people can download it, and I’ll hopefully have an online user guide.

    Screenshot:
    http://www.obscuresounds.com/obscureavatar-beta.jpg

    For now it works like this:

    1. designers can create transparent png “parts” of an avatar divided in to 3 sections (body, face, head).
    2. the plugin can differentiate between male and female by parsing in a string (m, or f), so again designers can create gender specific avatars based on needs.
    3. users who upload avatars via BP will bypass obscureavatars, and the plugin will only use gravatar as a last resort for groups, and blogs.
    4. it works for both wordpress, and buddypress.

    Essentially it sets out to do what I’ve wanted – to make the avatars a bit easier to work with for designers. Although I mainly develop backend stuff I love UI design, and one thing I’ve noticed is that pretty much all wordpress projects either use gravatars tacky generated content, or the dull wordpress avatar. Not only that but they fail to facilitate basic gender styles, which is essential for social network propagation now-days.

    I want to continue developing this in to something more sophisticated (I’m thinking it would be cool if designers could zip their parts in to packs, so that people can interchange them in an instant), but I will only be able to do this based on its popularity and support.

    #112060
    jamz86
    Member

    If you’re trying to pull just the avatar from within a loop, this shows how to do that:

    http://wpmu.org/how-to-create-a-gallery-of-members-avatars-in-buddypress/

    If you’re trying to pull up someone’s avatar simply by ID, use bp_core_fetch_avatar() like this:

    `
    <?php
    global $bp;
    $the_avatar = $bp->displayed_user->id; //you’d put in whatever function you’re using to get the ID here, assign it to a variable
    echo bp_core_fetch_avatar( ‘item_id=’.$the_avatar );
    ?>
    `

    Look up bp_core_fetch_avatar() as there are a lot more options than this. For example, do you want a thumbnail or full sized image? There is a way to specify. Hope that helps!!

    #112002
    Boone Gorges
    Keymaster

    Exactly what is your AJAX returning? Is the first part (span.searchheading) coming through OK?

    You might try (just for the heck of it) switching your argument structure to an array, something like this:
    echo bp_core_fetch_avatar( array( 'item_id' => $row ) );

    Theoretically, it shouldn’t matter, but sometimes it does.

    If you’re still having troubles, start dropping var_dump() statements into bp_core_fetch_avatar() itself. You can find that function in bp-core/bp-core-avatars.php.

    #111285
    Brandon Allen
    Participant

    You can easily change the default avatar in your dashboard under BuddyPress > General Settings. The reason it doesn’t use the WordPress avatar setting is because BuddyPress is designed to be it’s own site with it’s own settings. If you want to disable gravatar support completely you can set no_grav to true in your theme’s bp_core_fetch_avatar function calls. This will be made even easier when 1.3 is released.

    #111228
    r-a-y
    Keymaster

    BP_AVATAR_ORIGINAL_MAX_WIDTH is used during the initial upload. However, during the cropping phrase, this original image is deleted.

    It would be possible to do what you’re asking, but it would entail hooking into the avatar cropping process (so the original image isn’t removed) and filtering bp_core_fetch_avatar() to grab this original image when you want to call it.

    #110582

    Hmm… ok thanks. I copied the file from that template and pasted it in my file. Looks like it fixed that error but now i got another one!! :(

    `Fatal error: Call to undefined function: bp_core_fetch_avatar( $args = ” ) in /home/***/****/****/bp-core/bp-core-avatars.php on line 60`

    Henry
    Member

    Hope you do well with this, I would also be interested in using this.

    I’m sure many others would too!

    tiki16
    Participant

    Hi I am looking to utilise something like this. Any progress?
    thanks

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

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