Search Results for 'bp_core_fetch_avatar'
-
AuthorSearch Results
-
March 26, 2015 at 1:37 am #236638
In reply to: User avatar in side widget
shanebp
Moderator<?php $user_id = get_current_user_id(); ?> <a href="<?php echo bp_core_get_user_domain( $user_id ); ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_id ) ); ?></a>March 13, 2015 at 11:04 pm #235984In reply to: Using BuddyPress profile image
shanebp
ModeratorYour request is more properly asked of the plugin creator.
You could try this:
Open birds-author-box\public\frontend.php and replace this:if (get_the_author_meta('image', get_query_var('author'))) { $content.= '<img class="birds_box_avatar" src="' . get_the_author_meta('image', get_query_var('author')) . '">'; } else { $blank = plugin_dir_url(__FILE__) . 'img/blank.png'; $content.= '<img class="birds_box_avatar" src="' . $blank . '">'; }with this:
$avatar_args = array( 'item_id' => get_the_author_meta('ID', get_query_var('author')), 'type' => 'thumb', 'html' => false ); $content.= '<img class="birds_box_avatar" src="' . bp_core_fetch_avatar( $avatar_args ) . '">';March 4, 2015 at 10:05 pm #235469In reply to: If a number have same number get_avatar
tipsy
Participantthank you @danbp I will start right away!
Here is were I am now (not working):
<?php if ($entry[1] == xprofile_get_field_data(2, $user_id)); { echo bp_core_fetch_avatar($user_id); } ?>March 4, 2015 at 9:21 pm #235466In reply to: If a number have same number get_avatar
danbp
ParticipantOctober 1, 2014 at 6:58 am #203190In reply to: [Resolved] Remove GRAVATAR completely
danbp
Participantthe link given by @drakedoc was started over 4 years. Many solutions are given in this thread, and the last one was published a year ago.
That solution works for 1.9 and above !
/* Skip the Gravatar check when using a default BP avatar */ add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );By the way you have also to modify the global WP setting of avatars to “mystery man” or “nothing”.
Another solution to avoid gravatars slowing down a big site (at least > 500 members), is to use a specific cache plugin like Nix Gravatar Cache. Complete list here.
September 17, 2014 at 11:53 am #197233In reply to: Profile picture to use wordpress avatar
Henry Wright
ModeratorHi @tightflks
You can use
get_avatar()instead of the BuddyPress functionbp_core_fetch_avatar(). See: https://codex.wordpress.org/Function_Reference/get_avatarAugust 21, 2014 at 2:09 pm #187695In reply to: Please help – Use WordPress Avatars not BuddyPress?
Henry Wright
ModeratorThere might actually be more things you’d need to do. For example, the
bp_get_message_thread_avatar()function usesbp_core_fetch_avatar()so you would need to filter that usingbp_get_message_thread_avataretc.Unless someone else knows of an easier way, it seems as though it’ll be a big task of going through everything. You’d also need to be comfortable with PHP.
Alternatively, you could try disabling avatars by adding this to your bp-custom.php file
define( 'BP_SHOW_AVATARS', false );Note: I’ve not tested that, I’m just going on what I see at the beginning of the
bp_core_fetch_avatar()function. i.e:// If avatars are disabled for the root site, obey that request and bail if ( ! buddypress()->avatar->show_avatars ) return;August 21, 2014 at 1:53 pm #187692In reply to: Please help – Use WordPress Avatars not BuddyPress?
Martin Waller
ParticipantOkay, so searching that GitHub repo there is only one file under the bp-themes/bp-legacy/buddypress folders which mentions
bp_core_fetch_avatar()(but lots within the core BuddyPress code. So I just need to replace the reference in that one file and add it to by child theme under a BuddyPress folder and it should work?August 21, 2014 at 11:19 am #187685In reply to: Please help – Use WordPress Avatars not BuddyPress?
Martin Waller
ParticipantThanks @henrywright…
I’m not entirely sure that my front-end template actually references bp_core_fetch_avatar() as it is not a BuddyPress theme but rather a regular WordPress theme (Responsive Pro).
Martin
August 21, 2014 at 11:17 am #187684In reply to: Please help – Use WordPress Avatars not BuddyPress?
Henry Wright
ModeratorActually scratch that last post – it’s now displaying the avatars as the WordPress avatars in the back-end but not the front end
In that case, I think we’ve just crossed that bridge hehe. i.e the next step will be to replace all instances of
bp_core_fetch_avatar()in your front-end templates withget_avatar()August 21, 2014 at 10:53 am #187679In reply to: Please help – Use WordPress Avatars not BuddyPress?
Henry Wright
ModeratorHumm.. not helpful then. In that case we might have to try doing it manually. Perhaps try disabling the filter which replaces the WP avatars with BP avatars. For example, add this to your theme’s functions.php file:
remove_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 5 );I think you can disable the Gravatar fallback as well with this:
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );If that doesn’t work, you may need to replace all occurrences of
bp_core_fetch_avatar()withget_avatar()in your templates. But cross that bridge when you come to it.Ref: https://codex.wordpress.org/Function_Reference/get_avatar
August 18, 2014 at 6:52 pm #187149In reply to: Get E-mail addresses of users without Photos?
adamt19
ParticipantThis worked for me
function no_photos() { global $wpdb; $nophotoids = array(); $ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->prefix}users" ); foreach( $ids as $id ) { $avatar_check = false; if ( preg_match('/mystery-man.jpg/', bp_core_fetch_avatar( array( 'item_id' => $id, 'no_grav' => true, 'html'=> false ) ) ) ) $avatar_check = true; if( ! $avatar_check ) { $nophotoids[] = $id; } } $nophotoids = implode(",", $nophotoids); echo 'no photo ids: ' . $nophotoids; }July 2, 2014 at 11:49 pm #184752In reply to: Get E-mail addresses of users without Photos?
shanebp
Moderatoruntested:
function no_photos() { global $wpdb; $emails = array(); $ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->prefix}users" ); foreach( $ids as $id ) { $avatar_check = false; if ( bp_core_fetch_avatar( array( 'item_id' => $id, 'no_grav' => true, 'html'=> false ) ) != bp_core_avatar_default() ) $avatar_check = true; if( ! $avatar_check ) { $email = $wpdb->get_var( "SELECT user_email FROM {$wpdb->prefix}users WHERE ID = $id" ); $emails[] = $email; } } $emails = implode(",", $emails); return $emails; }May 30, 2014 at 5:50 pm #183495rodhewitt
ParticipantHello im looking for same solution , im looking for days, all solutions uses too many CPU resources because avatars are not stored in database
I found this code add to functions.php but its not working for me
________________________________________________________________________________________________
//Hide members without avatars
add_action( ‘bp_core_delete_existing_avatar’, ‘log_avatar_deleted’ );
add_action( ‘xprofile_avatar_uploaded’, ‘log_avatar_uploaded’ );//on new avatar upload, record it to user meta
function log_avatar_uploaded(){
update_user_meta(bp_loggedin_user_id(), ‘has_avatar’, 1);
}//on delete avatar, delete it from user meta
function log_avatar_deleted($args){
if($args[‘object’]!=’user’)
return;
//we are sure it was user avatar delete
//remove the log from user meta
delete_user_meta(bp_loggedin_user_id(), ‘has_avatar’);
}function modify_loop_and_pag($qs, $object=false) {
global $wpdb;
$include = ”;if( $object != ‘members’ )//hide for members only
return $qs;$subscribers = $wpdb->get_results(“SELECT user_id FROM {$wpdb->usermeta } WHERE meta_key=’has_avatar'” , ARRAY_N );
foreach($subscribers as $subscriber){
$include = $include . “,” . $subscriber[0];
}$args = wp_parse_args( $qs );
//check if we are listing friends?, do not apply in this case
if( !empty( $args[‘include’] ) ) {
$args[‘include’] = $args[‘include’] . ‘,’ . $include;
}
else {
$args[‘include’] = $include;
}$qs = build_query($args);
return $qs;
}
add_action( ‘bp_ajax_querystring’ , ‘modify_loop_and_pag’, 25, 2 );function current_user_has_avatar($id) {
global $bp;
if ( bp_core_fetch_avatar( array( ‘item_id’ => $id, ‘no_grav’ => true,’html’=> false ) ) != bp_core_avatar_default( ‘local’ ) ) {
return true;
}
return false;
}// ATTENTION
// This code should be deleted after first site load with the code
//
function init_avatar_meta(){
global $wpdb;
$ids=$wpdb->get_col(“SELECT ID FROM $wpdb->users”);//we don’t need to check for meta value anyway
foreach( $ids as $id ){
if( current_user_has_avatar($id) ){
update_user_meta( $id, ‘has_avatar’, 1 );
} else {
delete_user_meta( $id, ‘has_avatar’ );
}
}
}
add_action(‘init’, ‘init_avatar_meta’);May 30, 2014 at 12:37 am #183465In reply to: How to properly filter bp_member_avatar
shanebp
Moderator$defaults aren’t being passed by the filter.
Try:
add_filter('bp_member_avatar', 'mm_hide_name_in_alt_text', 1); function mm_hide_name_in_alt_text( $var ) { var_dump( $var ); return $var; }Then you should be able to tell what is being passed to the filter and adjust it accordingly.
You could also use the filters in bp_core_fetch_avatar()March 18, 2014 at 2:35 pm #179965In reply to: Detecting if User Uploaded an Avatar
wp_kouhai
ParticipantI have found and corrected the issue.
function buddypress_redirect_if_no_avatar($redirect_url,$request_url,$user) { $avatar = bp_core_fetch_avatar( array( 'item_id' => $user->ID, 'no_grav' => true, 'html'=>false) ); $pos = strpos($avatar, 'mystery-man'); if ($pos === false) { return "/";} else { $redirect_url = bp_core_get_user_domain($user->ID)."/profile/change-avatar/"; return $redirect_url; } } add_filter("login_redirect","buddypress_redirect_if_no_avatar",100,3);March 9, 2014 at 7:25 pm #179514In reply to: 3rd Sized Avatar
Henry Wright
ModeratorSo, with the code I suggested in place. You can output the 3 sized avatars on your site like this:
Thumb size:
$type = 'thumb'; $width = 200; $height = 200; $user_fullname = bp_get_loggedin_user_fullname(); $user_id = bp_loggedin_user_id(); echo bp_core_fetch_avatar( array( 'alt' => $user_fullname, 'class' => 'avatar', 'width' => $width, 'height' => $height, 'item_id' => $user_id, 'type' => $type, 'title' => $user_fullname ) );Full size:
$type = 'full'; $width = 500; $height = 500; $user_fullname = bp_get_loggedin_user_fullname(); $user_id = bp_loggedin_user_id(); echo bp_core_fetch_avatar( array( 'alt' => $user_fullname, 'class' => 'avatar', 'width' => $width, 'height' => $height, 'item_id' => $user_id, 'type' => $type, 'title' => $user_fullname ) );Tiny thumb size:
$width = 20; $height = 20; $user_fullname = bp_get_loggedin_user_fullname(); $user_id = bp_loggedin_user_id(); echo bp_core_fetch_avatar( array( 'alt' => $user_fullname, 'class' => 'avatar', 'width' => $width, 'height' => $height, 'item_id' => $user_id, 'title' => $user_fullname ) );Note: It isn’t recommended to change core files in this way because you’ll lose the changes you made on each upgrade. But it’s what you asked for so… 🙂
March 9, 2014 at 3:04 pm #179509In reply to: 3rd Sized Avatar
darqpony
ParticipantYes! that! Since I know so little about php coding, I didn’t know WHAT to do instead of the choice it gave me or where to look.
1. I understand about the upgrade will overwrite thing. If I put this bit of code in my bpcustom.php file, will it override the original “$avatar_size = ( ‘full’ == $type ) ? ‘-bpfull’ : ‘-bpthumb;” or do I have to somehow negate that first in the bpcustom file?
2. I have this in the bp_core_fetch_avatar:
function bp_core_fetch_avatar( $args = '' ) { // If avatars are disabled for the root site, obey that request and bail if ( ! buddypress()->avatar->show_avatars ) return; global $current_blog; $bp = buddypress(); // Set a few default variables $def_object = 'user'; $def_type = 'thumb'; $def_class = 'avatar'; // Set the default variables array $params = wp_parse_args( $args, array( 'item_id' => false, 'object' => $def_object, // user/group/blog/custom type (if you use filters) 'type' => $def_type, // tinythumb, thumb or full 'avatar_dir' => false, // Specify a custom avatar directory for your object 'width' => false, // Custom width (int) 'height' => false, // Custom height (int) 'class' => $def_class, // Custom <img> class (string) 'css_id' => false, // Custom <img> ID (string) 'alt' => '', // Custom <img> alt (string) 'email' => false, // Pass the user email (for gravatar) to prevent querying the DB for it 'no_grav' => false, // If there is no avatar found, return false instead of a grav? 'html' => true, // Wrap the return img URL in <img /> 'title' => '' // Custom <img> title (string) ) ); extract( $params, EXTR_SKIP );Where do I ‘pass’ thumb or full to it? Or is it already there in this original since I haven’t changed anything yet?
3. If I change the bp_core_fetch_avatar, do I have to somehow change the first 1.’s solution?
4. Should I post this on the other site you found my question on? LOL (Hey, I gave it two days before trying a different site! But got the same guy answering… go figure… LOL)
… and yes, it did use the tinythumb type and it did make the thumb sized avatar fuzzy. I have an avatar for that size. I want it to use it! LOL I want to use ALL my avatars!
March 9, 2014 at 6:49 am #179497In reply to: 3rd Sized Avatar
Henry Wright
ModeratorYou’d change
$avatar_size = ( ‘full’ == $type ) ? ‘-bpfull’ : ‘-bpthumb;to:if ($type == 'full' ) { $avatar_size = '-bpfull'; } elseif ($type == 'thumb' ) { $avatar_size = '-bpthumb'; } else { $avatar_size = '-bptinythumb'; }But that approach wouldn’t be recommended because when you upgrade buddypress your changes will be lost.
The tiny thumb will be the default avatar size. If you wanted to use the thumb or full versions then you’d need to pass
thumborfullto bp_core_fetch_avatarMarch 8, 2014 at 6:35 pm #179475In reply to: 3rd Sized Avatar
darqpony
ParticipantYes, I already have the different various sizes of avatar. I have the Tinythumb, Thumb, and Full sizes. And I can change them to whatever width and height I’d like them to be. I could make miiiiyyyons of them if I so chose. Thumb1, Thumb2, Thumb3, etc. . . . Not the issue. I’m stuck in the calling of them to my themes widget. I can call only two of those sizes. If I change $avatar_size = ( ‘full’ == $type ) ? ‘-bpfull’ : ‘-bpthumb’; to add ‘-bptinythumb’, it defaults back to the default of full and bpfull or bpthumb. I can’t get it to USE bptinythumb in the theme. Or in actuality, to USE more than two, hence I need it to SEE the third size avatar.
🙂
And thanks so much for taking a look at this guys.
PS: And I’m gonna check to see what bp_core_fetch_avatar does… maybe rewriting it will get me what I want. Maybe you guys know already how I should rewrite it? *Hint hint* LOL
March 8, 2014 at 12:39 pm #179470In reply to: 3rd Sized Avatar
Henry Wright
ModeratorHi @darqpony
1. Thumbs
define ( 'BP_AVATAR_THUMB_WIDTH', 20 ); define ( 'BP_AVATAR_THUMB_HEIGHT', 20 );2. Full
define ( 'BP_AVATAR_FULL_WIDTH', 150 ); define ( 'BP_AVATAR_FULL_HEIGHT', 150 );3. Original
define ( 'BP_AVATAR_ORIGINAL_MAX_WIDTH', 300 );4. File size
define ( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', $max_in_kb );Now, you can use
bp_core_fetch_avatarto output either the thumb or the full size avatar. This doesn’t cover the original. You could write your own version ofbp_core_fetch_avatarwhich will output the original as well. That’s if the original is saved. You’ll have to check that it is. I’m sure it will be but have never needed to use it so you might want to make sure.March 3, 2014 at 2:04 am #179201In reply to: remove all gravatar calls
modemlooper
Moderatoradd this to your bp-custom.php file
add_filter('bp_core_fetch_avatar_no_grav', '__return_true');February 6, 2014 at 6:45 pm #178036In reply to: How to access Buddypress avatar not on profile page
Henry Wright
ModeratorHi
Try:
echo bp_core_fetch_avatar( array( 'alt' => 'Profile picture of ' . bp_get_loggedin_user_fullname(), 'class' => 'avatar', 'width' => 50, 'height' => 50, 'item_id' => bp_loggedin_user_id(), 'type' => 'full', 'title'=> bp_get_loggedin_user_fullname() ) );January 6, 2014 at 3:33 pm #176486In reply to: avatar width doesn't apply
Henry
MemberNot saying this is the problem because I have very limited PHP knowledge but maybe that’s where echo bp_core_fetch_avatar( array(… is getting it’s Avatar from.
I can’t seem to duplicate the problem. It actually works for me.
Can you try using Twenty Thirteen? If that works then that shows something has been introduced (perhaps in your theme or maybe a plugin) which is conflicting with the function.
January 6, 2014 at 1:31 pm #176483In reply to: avatar width doesn't apply
Shmoo
ParticipantNo not really, the only places where I’ve changed the avatar sizes is inside BP page templates like this,
<?php bp_the_thread_message_sender_avatar( 'type=thumb&width=64&height=64' ); ?> .... <?php bp_loggedin_user_avatar( 'type=thumb&height=64&width=64' ); ?> .... <?php bp_member_avatar( 'height=192&width=192' ); ?> .... <?php bp_displayed_user_avatar('type=full&height=192&width=192'); ?>I’m using functions.php to add custom codes, but no avatar related code inside that.
I did a search at bp_core_fetch_avatar and found this at bp-core-tamplet.php
/** * Output a post author's avatar. * * Not currently used in BuddyPress. * * @todo Deprecate. */ function bp_post_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' => 'thumb', 'alt' => sprintf( __( 'Avatar of %s', 'buddypress' ), bp_core_get_user_displayname( $post->post_author ) ) ) ) ); else if ( function_exists('get_avatar') ) get_avatar(); }This is the first time I can track bp_core_fetch_avatar as a function combined with an array() and look there is no width and height inside that array only thumb and alt.
Not saying this is the problem because I have very limited PHP knowledge but maybe that’s where echo bp_core_fetch_avatar( array(… is getting it’s Avatar from.
-
AuthorSearch Results