Search Results for 'bp_core_fetch_avatar'
-
AuthorSearch Results
-
September 14, 2018 at 9:36 am #276394
In reply to: Changing Avatar based on field data
Prashant Singh
ParticipantHi,
There is a filter code already written to modify this: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 ) ) );You can use this filter to write your own code to modify the class parameter.
Thanks
September 3, 2018 at 7:15 am #276090T_ed
ParticipantI have both Buddypress and bbpress installed. bbpres is using local wordpress avatars that registered users uploaded even before bbpress was installed. I want Buddypress to do the same – use these local avatars instead of its own. I have found this code on bbpress codex and internets:
add_filter('bp_core_fetch_avatar_no_grav', '__return_true');I added this code to bp-custom.php, but it`s seems like this code is not working anymore? I really need to make Buddypress to use local avatars just like bbpress do, please help.
June 21, 2018 at 2:31 pm #274623In reply to: Default Profile Photo
Venutius
ModeratorJust tested it, create a bp-custom.php in your plugins directory and add the following:
define ( 'BP_AVATAR_DEFAULT', 'http://example.com/default-avatar.jpg' ); define ( 'BP_AVATAR_DEFAULT_THUMB', 'http://example.com/default-avatar-thumb.jpg' ); add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );March 31, 2018 at 8:56 pm #271679In reply to: changing default avatar – codex info not working
Jonas
ParticipantDigging into it a bit more, it seems gravatars influences it. You can disable the gravatars like so
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );followed by using your original code
define ( 'BP_AVATAR_DEFAULT', 'http://example.com/default-avatar.jpg' ); define ( 'BP_AVATAR_DEFAULT_THUMB', 'http://example.com/default-avatar-thumb.jpg' );February 21, 2018 at 9:35 pm #270956In reply to: Moving the group header and image
David Cavins
KeymasterHi I’m not exactly sure what you mean, but if you’re looking to get the profile image associated with a group or user, you can use the avatar-fetching function that BP uses in its templates,
bp_core_fetch_avatar():
https://buddypress.trac.wordpress.org/browser/tags/2.9.3/src/bp-core/bp-core-avatars.php#L99As an example, you might use
bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => false, 'height' => false, 'html' => true, 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), 'user name' ) ) );November 3, 2017 at 5:14 pm #268808In reply to: Goodbye Buddypress?
David Cavins
KeymasterHi @VentureCore-
It seems like you can make avatars work remotely. Check
bp_core_fetch_avatar()for some filter opportunities. https://buddypress.trac.wordpress.org/browser/tags/2.9.2/src/bp-core/bp-core-avatars.php#L98I’ve not done what you’re trying to do, but it seems that the filter points
bp_core_avatar_folder_url,bp_core_avatar_folder_dircould be useful, but there’s a filter on the final result atbp_core_fetch_avatarfor the “html” output version andbp_core_fetch_avatar_urlfor just the url.Cover images should actually be easier to manage. Take a look in https://buddypress.trac.wordpress.org/browser/tags/2.9.2/src/bp-core/bp-core-attachments.php#L28
Alternatively, you could filter the other plugin to ignore avatar and cover image requests. Lots of ways to solve this, I’d bet.
June 14, 2017 at 10:08 pm #266477In reply to: Slow for logged-out users
n0madpl
ParticipantHey,
The fix for that is coming in the next release of buddy press. Or at least for the part of the problem.
You most likely get 50% of your problem from these two in my case with 6k users these amounted to the respective query execution times (from new relic), I also run buddypress + rtmedia (which is the source of this problem) as described in this ticket:
bp_friends_prime_mentions_results – 10,000+ ms
bp_core_fetch_avatar – 6,000+ msHere’s a fix:
https://buddypress.trac.wordpress.org/changeset/11561You’ll still likely stay with this massive query even for logged out users:
WP_User_Query::query on average right now it’s at around 7,500ms.Good news is that with HHVM site runs much faster due to object caching straight after enabling it.
I’ve also played around with various hosts, flywheel & wpengine sucked. What works well is Kinsta with HHVM enabled, they can also check your database and help you move to InnoDB if you’re using another one.
Anyway man hope this helps.
Best,
M.
June 12, 2017 at 1:18 am #266431In reply to: Customizing BuddyPress Avatars – BROKEN??
coolhunt
ParticipantThis worked!
adding
add_filter('bp_core_fetch_avatar_no_grav', '__return_true');this is what my bp-custom looks like now to make it work:
define('BP_DEFAULT_COMPONENT', 'profile' ); define ( 'BP_AVATAR_THUMB_WIDTH', 125 ); define ( 'BP_AVATAR_THUMB_HEIGHT', 125 ); define ( 'BP_AVATAR_FULL_WIDTH', 150 ); define ( 'BP_AVATAR_FULL_HEIGHT', 150 ); add_filter('bp_core_fetch_avatar_no_grav', '__return_true'); define ( 'BP_AVATAR_DEFAULT', 'https://veloXXXXXXXhive.com/wp-content/uploads/2017/06/VeloHive-Default-User-Avatar-150px-x-150px-17Teeth-EVO.png' ); define ( 'BP_AVATAR_DEFAULT_THUMB', 'https://veloXXXXXXhive.com/wp-content/uploads/2017/06/VeloHive-Default-User-Avatar-125px-x-125px-17Teeth-EVO-THUMBNAIL.png' );Someone should probably update that codex doc
February 17, 2017 at 11:13 pm #263898Sergio Peña
ParticipantHere’s the code for anyone who wants to do the same:
add_shortcode('course_mentor','group_course_mentor'); function group_course_mentor($atts, $content = null){ if(!is_user_logged_in()) return; if(!bp_is_active('groups')) return; global $wpdb,$bp; $batches = groups_get_user_groups(get_current_user_id()); $return = ''; if(!empty($batches['groups'] )){ foreach($batches['groups'] as $batch){ $admins = groups_get_group_admins( $batch ); foreach($admins as $admin){ $return .= '<a href="'.bp_core_get_user_domain($admin->user_id).'" title="'. bp_core_get_user_displayname( $admin->user_id, true ) .'">'.bp_core_fetch_avatar ( array( 'item_id' => $admin->user_id, 'type' => 'thumb' ) ) .'</a>'; } } } return $return ; }Credit goes to Alex @ WPLMS for this 🙂
February 14, 2017 at 11:59 pm #263779Sergio Peña
ParticipantThank you for your response.
I did ask Learndash and they referred me to third party programmers.
Since I am using buddypress groups, I thought it was appropriate to ask here as well. Apologies if I was mistaken!
So would it be something like this:
add_shortcode('course_mentor','nex_course_mentor'); function nex_course_mentor($atts, $content = null){ if(!is_user_logged_in()) return; if(!bp_is_active('groups')) return; $nex_group_id = bp_get_group_id(get_current_user_id()); if(!empty($nex_group_id)){ foreach($nex_group_id as $nex_group_id){ $nex_admins = groups_get_group_admins( $nex_group_id ); foreach($admins as $admin){ ?> <a href="<?php echo bp_core_get_user_domain($admin->user_id) ?>" title="<?php echo bp_core_get_user_displayname( $admin->user_id, true ) ?>"> <?php echo bp_core_fetch_avatar ( array( 'item_id' => $admin->user_id, 'type' => 'thumb' ) ) ?></a>'; <?php } } } }I’m just copy/pasting and trying to connect a bunch of different answers together. As you can tell, I’m no coder.
Since each group may have more than one group leader/mentor I had a loop in there. Hopefully that will get the ball rolling on what I’m trying to do.
Am I on the right track?
January 13, 2017 at 7:03 pm #262809In reply to: BP_AVATAR_DEFAULT_THUMB issue
brightwash
Participantdefine ( ‘BP_AVATAR_DEFAULT_THUMB’, $img_url );
This was not working for me either, in the end this combination did. Turning off gravatar (first filter), and then a default bp image filter.
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' ); add_filter( 'bp_core_default_avatar_user', 'override_default_avatar', 10, 2 ); function override_default_avatar( $default, $params ) { if ( !empty($params) ) { if ( 'thumb' == $params['type'] ) { return get_stylesheet_directory_uri() . '/img/avatar-thumb.jpg'; } } return get_stylesheet_directory_uri() . '/img/avatar.jpg'; }December 7, 2016 at 12:25 am #261814In reply to: Duplicate Queires
daniel27lt
ParticipantSo this doesn’t matter then when
update_meta_cacheis called twice?It seems to be calling 2 queries and one of them
bp_core_fetch_avatar_filterIt’s just because I’m sure (not 100%) that I’ve never seen this show up until now.
June 17, 2016 at 2:20 pm #254737In reply to: global avatar
danbp
ParticipantSeveral topics are related to your question on the forum.
June 14, 2016 at 4:48 am #254536In reply to: WP User Avatar Not Showing in BuddyPress
r-a-y
KeymasterSo what you’re looking for is to use a custom user avatar instead of BuddyPress’?
Try the following code snippet in your theme’s
functions.phporwp-content/plugins/bp-custom.php:remove_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 6 );Update – That code snippet only reverts the avatar in WordPress posts and comments.
To override BuddyPress avatars in BuddyPress content with a custom avatar solution, you would have to hook into the
'bp_core_fetch_avatar'filter:
https://buddypress.trac.wordpress.org/browser/tags/2.5.3/src/bp-core/bp-core-avatars.php?marks=534-549#L534June 8, 2016 at 8:14 am #254313In reply to: How to make group avatars sharper
Henry Wright
ModeratorYou could be using the thumb sized avatar. Check your theme to make sure the full sized image is being used.
bp_core_fetch_avatar()is the function used by BuddyPress to display avatars but there’s alsoget_avatar()so check for that too (it’s a WordPress function).June 3, 2016 at 8:30 am #254089In reply to: Show Member profile photo on category stream
danbp
ParticipantSee if this helps. http://hookr.io/plugins/buddypress/2.4.3/functions/bp_core_fetch_avatar/
May 15, 2016 at 10:58 am #253393In reply to: Display Avatar in Widget Comment
Henky
Participant<?php echo get_avatar( $comment, ’45’ ); ?>
<?php echo bp_core_fetch_avatar( array( ‘item_id’ => $comment->user_id,’type’ => ‘full’,’width’ => 75,’height’ => 75)); ?>April 24, 2016 at 6:41 pm #252860In reply to: Avatars reset to default when activating BuddyPress
Henry Wright
ModeratorHi @etavio
Your custom plugin is most likely filtering
get_avatarto display your custom images. BuddyPress actually bypasses that filter through the use ofbp_core_fetch_avatar().Ref: https://github.com/buddypress/BuddyPress/blob/master/src/bp-core/bp-core-avatars.php#L192
You will need to use a different filter.
March 17, 2016 at 10:58 pm #251396In reply to: BP_AVATAR_DEFAULT_THUMB issue
danbp
ParticipantHi,
default avatar is ‘gravatar’ ‘s mytery man. To use your own avatar, you have to deactivate gravatar in addition to constant. Try this in bp-custom.php
add_filter('bp_core_fetch_avatar_no_grav', '__return_true'); define ( 'BP_AVATAR_DEFAULT_THUMB', 'YOURIMAGEURL' );March 10, 2016 at 1:18 pm #250977In reply to: Avatar images on 3rd party plugin
tkuron
ParticipantI managed to fix the issue.
Apparently BuddyPress does not change the avatar url when get_avatar_data() -function is called. I managed to fix the issue by adding following piece of script to my plugin’s source code:
<?php add_filter("get_avatar_data", function($args, $id_or_email){ $bp_avatar_url = bp_core_fetch_avatar([ "html" => false, "item_id" => $id, "type" => "full", "width" => $args["size"], "height" => $args["size"] ]); $bp_avatar_url = htmlspecialchars_decode($bp_avatar_url); $args["url"] = $bp_avatar_url; return $args; }, 10, 2); ?>March 10, 2016 at 11:31 am #250975In reply to: Avatar images on 3rd party plugin
Henry Wright
ModeratorIf it’s a BuddyPress page then I guess the
bp_core_fetch_avatar()function should display the local avatar if no Grav exists. Are you saying this doesn’t happen?March 10, 2016 at 10:51 am #250971In reply to: Avatar images on 3rd party plugin
Henry Wright
ModeratorYou could disable Gravatar?
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );February 12, 2016 at 12:08 pm #249815In reply to: Problem displaying user avatar
Florent
ParticipantTopic close as result is already formated :
http://hookr.io/functions/bp_core_fetch_avatar/Usage
$string = bp_core_fetch_avatar( $args );
Parameters
$args
( array|string ) optional – { An array of arguments. All arguments are technically optional; some will, if not provided, be auto-detected by bp_core_fetch_avatar(). This auto-detection is described more below, when discussing specific arguments.Returns
string Formatted HTML
element, or raw avatar URL based on $html arg.
November 28, 2015 at 2:24 pm #247239In reply to: Changing avatar images and profile links
Henry Wright
Moderatorbp_core_default_avatar_userwill fire only if you have disabled Gravatar via thebp_core_fetch_avatar_no_gravhook.November 20, 2015 at 6:17 pm #247012In reply to: How to update avatar user meta?
r-a-y
KeymasterWe do not store avatar data in the database.
We do a look up at the files level instead.
If you want to show an avatar based on a custom avatar stored in the database, you’ll need to use the
'bp_core_fetch_avatar'filter to override how BuddyPress shows avatars:
https://buddypress.trac.wordpress.org/browser/tags/2.4.0/src/bp-core/bp-core-avatars.php?marks=531-546,660-664#L531If you just want to display a user avatar, use the
bp_core_fetch_avatar()function:echo bp_core_fetch_avatar( array( 'item_id' => USER_ID_TO_GRAB_AVATAR_FOR ) ); -
AuthorSearch Results