Search Results for 'bp_core_fetch_avatar'
-
AuthorSearch Results
-
November 28, 2011 at 1:26 am #125115
In reply to: Getting the BP post author avatar outside of loop.
r-a-y
KeymasterYou 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.
November 24, 2011 at 4:46 pm #124958julien760
Memberhello,
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 ‘‘;
}
if ( bp_get_profile_field_data( ‘field=Gender’ ) == ‘Male’ ) {
$default = get_stylesheet_directory_uri() .’/images/def_m_avatar.gif’;
return ‘‘;
}
else {
return $image;
}
} else {
return $image;
}
}
add_filter(‘bp_core_fetch_avatar’, ‘bp_remove_gravatar’, 1, 9 );October 21, 2011 at 3:05 am #123242In reply to: Displaying User Avatar with activity
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?
September 7, 2011 at 11:12 pm #119714In reply to: Need some suggestions on this…
modemlooper
ModeratorFound 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.
August 28, 2011 at 4:10 am #119169In reply to: Getting group avatar, outside of loop.
dyerrington
MemberSolution: 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.
August 27, 2011 at 5:36 pm #119149In reply to: Getting group avatar, outside of loop.
dyerrington
MemberAlright, 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.
August 22, 2011 at 8:52 pm #118867In reply to: Caching the response of fetch_avatar
gordyr
MemberCode:<?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>
August 8, 2011 at 2:24 am #117959In reply to: Avatar Upload Problem During Registration
rbbp22
MemberMe 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.phpchange
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.
July 28, 2011 at 10:12 pm #117123@mercime
ParticipantReferencing your trac ticket https://buddypress.trac.wordpress.org/ticket/3405
June 18, 2011 at 2:47 am #114752ramprakav
Memberthere is a problem in that avatar so i cant upload my avatar
June 17, 2011 at 9:46 pm #114732sidjags
Memberhello 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:
sid
June 11, 2011 at 9:07 pm #114373sidjags
Memberany progress? would love to see whats been done and test it out to see if we can use it… really looking forward to this.
May 26, 2011 at 11:31 pm #113151David Bisset
ParticipantThis is cool, i’ve been monitoring this off and on – glad to see you come through! Happy to test this one out.
May 26, 2011 at 10:44 pm #113150Lawrence
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.
May 26, 2011 at 10:25 pm #113149Paul Wong-Gibbs
KeymasterHey, looks like a novel approach — I’ll have a play when you get the plugin out
May 26, 2011 at 10:03 pm #113148Lawrence
ParticipantGood 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.jpgFor 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.
May 11, 2011 at 7:17 am #112060In reply to: How to print out an Avatar from a user ID
jamz86
MemberIf 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!!
May 10, 2011 at 8:19 pm #112002In reply to: Impossible to get avatars in a custom AJAX search?
Boone Gorges
KeymasterExactly 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.
April 29, 2011 at 1:15 am #111285In reply to: How to disable Gravatar completely?
Brandon Allen
ParticipantYou 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.
April 28, 2011 at 6:41 am #111228In reply to: Avatars Original Max not bein saved?
r-a-y
KeymasterBP_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.
April 19, 2011 at 10:27 pm #110582In reply to: Woke Up Mysteriously with a Fatal Error
Bigjimmysisco
MemberHmm… 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`
April 8, 2011 at 6:16 pm #109837Henry
MemberHope you do well with this, I would also be interested in using this.
I’m sure many others would too!
April 8, 2011 at 4:51 pm #109831tiki16
ParticipantHi I am looking to utilise something like this. Any progress?
thanksApril 6, 2011 at 6:20 pm #109684In reply to: [RESOLVED(ish)] Update avatar automagically
r-a-y
KeymasterCheck 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/March 29, 2011 at 1:59 pm #109040Lawrence
ParticipantThanks 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.
-
AuthorSearch Results