Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_fetch_avatar'

Viewing 25 results - 201 through 225 (of 310 total)
  • Author
    Search Results
  • #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.

    #23877
    dyerrington
    Member

    I’ve found only a few examples of using bp_get_group_avatar(). I can’t seem to get anything returned other then a blank image.

    http://phpxref.ftwr.co.uk/buddypress/bp-groups/bp-groups-template.php.source.html#l380

    So from this method, I’ve tried passing an item_id in the args array as the group ID and also bypassing this wrapper function by calling “bp_core_fetch_avatar()” but without much luck. It would be nice to throw an error or give some feedback other then an unexpected result.

    I would be happy to fetch something from the database if it where there but my best guess without getting too far into the code is that when that fancy jquery cropper thing hands off the file somewhere, it saves it using an MD5 or similar. I’ve spent plenty of hours looking at this by now and if I can do this the right way, I would prefer that then hacking this the wrong way.

    Could anyone give me some pointers? I have a group ID within a plugin I’m writing, I just want to have it return the avatar or even better yet a URL or filename. Using a method that echos an image tag in a loop is not very useful to me. I really need a method that returns something, not echo’ed

    Thanks!

    #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
    Kchun
    Participant

    At line 163 in file bp-core-avatars.php we need to add checking of the file time in order to be sure we are getting the most recent uploaded avatar:

    Add after:
    `
    // Check for array
    if ( 0 < count( $avatar_files ) ) {
    `
    These 2 lines:
    `
    $avatar_file_time=0;
    $avatar_home_path=str_replace($bp->root_domain,ABSPATH,$avatar_folder_url);
    `
    Modify the foreach loop that follows like this:

    // Check for current avatar
    foreach( $avatar_files as $key => $value ) {
    if ( strpos ( $value, $avatar_size )!== false ) {
    if($avatar_file_time< ($t=filemtime($avatar_home_path . '/' . $value))) { //NEW
    $avatar_file_time=$t; // THIS IS NEW
    $avatar_url = $avatar_folder_url . ‘/’ . $avatar_files[$key];
    }
    }
    }

    imjscn
    Participant

    I want to modify bp_core_fetch_avatar and use it for all components in my theme.
    Currently, I use ` ‘object’ => $bp->current_component`
    This gets correct avatar for all components but I need to use a javascript to do something on the avatars.
    So, I want to change all “object” to the same name so that the javascript can recon the elements.

    My question is— What will happen is all components’ avatar use the same object name? Deos it matter?

    #22803
    eac
    Member

    Hey,

    I have a folder of user images(2000+) and I’m looking to use these for the avatars of users in buddypress. I have buddypress sharing the wordpress user table and I have a plugin that picks up the users AD credentials and creates an account for them. I have a database that matches the AD credentials to the the users picture.

    Not sure what the best way to go about this would be. Should I create a plugin that overrides the bp_core_fetch_avatar filter?

    Any help would be appreciated.

    Thanks

    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.

    Doug
    Participant

    getting this message when i access site, i tried doing an update and it didnt work, i screwed up somewhere, this is the message…

    Fatal error: Cannot redeclare hide_activity() (previously declared in /home/content/34/7811134/html/thesoldiersnetwork/wp-content/themes/facelook/functions.php:18) in /home/content/34/7811134/html/thesoldiersnetwork/wp-content/plugins/buddypress/bp-themes/bp-default/functions.php on line 23

    this is the functions.php currently in that folder….

    <?php
    define( ‘BP_DTHEME_DISABLE_CUSTOM_HEADER’, true );

    //
    // Remove View links from activity items; most people use ‘Favorites’.
    add_filter(‘bp_activity_permalink’, create_function(‘$a’, “return null;”));

    //
    // Hide log-in error message from potential hackers.
    add_filter(‘login_errors’, create_function(‘$a’, “return null;”));

    //
    // Hide erm, what..? Useful though!
    remove_action(‘wp_head’, ‘wp_generator’);

    //
    // Hide last known logged-on time from non-members.
    function hide_activity($content) {
    if ( !is_user_logged_in() )
    $content=’Log-in to contact this member!’;

    return $content;
    }
    add_filter(‘bp_member_last_active’, ‘hide_activity’, $last_activity);
    add_filter(‘bp_last_activity’, ‘hide_activity’, $last_activity);

    // Only allow Send Private Message to friends
    function is_my_own_friend( $friend_id = false) {
    global $bp;

    if ( is_site_admin() )
    return true;

    if ( !is_user_logged_in() )
    return false;

    if (!$friend_id) {
    $potential_friend_id = $bp->displayed_user->id;
    } else {
    $potential_friend_id = $friend_id;
    }

    if ( $bp->loggedin_user->id == $potential_friend_id )
    return false;

    if (friends_check_friendship_status($bp->loggedin_user->id, $potential_friend_id) == ‘is_friend’)
    return true;

    return false;
    }

    // Fix in case of empty avatar (gravatar.com fetch removed in core files).
    function no_empty_avatar($avatar_link) {
    if ( strpos( $avatar_link, “src=”” ) ) {
    $avatar_link = str_replace(“src=””, “src='” . BP_AVATAR_DEFAULT . “‘”, $avatar_link );
    }
    return $avatar_link;
    }
    add_filter( ‘bp_core_fetch_avatar’, ‘no_empty_avatar’ );

    ?>

    help! thanks!

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

    jamz86
    Member

    Hi,

    I’m running BP 1.2.8 on WP 3.1 and I’ve created an AJAX/jQuery live search that’s a lot like Facebook’s. It works fine — however, no matter what I try, it seems to break every time I try to add avatars to the search results.

    Here’s the code I’m trying:

    
    $query_m = "SELECT ID, user_url, display_name FROM {$wpdb->prefix}_users WHERE display_name LIKE '%$keyword%' ORDER BY ID LIMIT 8";
    $result_m = mysqli_query($dbc,$query_m);
    if($result_m){
    if(mysqli_affected_rows($dbc)!=0){
    
    echo '<span class="category">Members</span>';
    
    while($row = mysqli_fetch_array($result_m,MYSQLI_ASSOC)){
    
    if(strlen($row) > 35) {
    $row = substr($row, 0, 35) . "...";
    }
    
    echo '<span class="searchheading"><a href="'.$row.'">'.$row.'</a></span>';
    
    echo bp_core_fetch_avatar('item_id='.$row );
    }
    }else {
    echo 'No Results for :"'.$_GET.'" in Members';
    }
    
    }
    

    I’ve also tried calling the $bp global right before bp_core_fetch_avatar, but it doesn’t seem to make a difference.

    Any help would be greatly appreciated!

    #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

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