Getting the large avatar
I’m using some PHP in a sidebar text widget to display a posts author and the xprofile fields for that user, plus the avatar.
I cannot seem to return the large version of the avatar, I’m getting a stretched version of the small avatar.
Can anyone advise?
<a href="/community/members/<?php echo get_the_author_meta('user_login') ?>"> <?php echo get_avatar ( get_the_author_meta('user_email'), $size = '192' ); ?> </a>
You’re using wordpress’s
bp_core_fetch_avataris what you’re looking for
Ah ok thanks, this code doesn’t seem to return anything, can you help me with the error?
<a href="/community/members/<?php echo get_the_author_meta('user_login') ?>"> <?php echo bp_core_fetch_avatar ( get_the_author_meta('user_email'), $size = '192' ); ?> </a>
@applegatein my bad, here
$params = wp_parse_args( $args, array( 'item_id' => false, 'object' => $def_object, // user/group/blog/custom type (if you use filters) 'type' => $def_type, // 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)
You’re using wordpress’s get_avatar is what you’re looking for
BuddyPress seems to attempt to filter get_avatar() – see bp_core_fetch_avatar_filter(). I did bring this issue up a while ago at WordPress Trac but the call was closed.
Wonder if anyone thinks it’s worthy of a BP Trac ticket?
I’ve just raised a BP Trac ticket for this
Ah so you think this can’t work as it stands @henrywright-1 ?
You could always att this to bp-custom.php
define ( 'BP_AVATAR_THUMB_WIDTH', 192 ); define ( 'BP_AVATAR_THUMB_HEIGHT', 192 );
Then use this in your post page
$author = get_the_author(); echo get_avatar( get_the_author_meta('ID'), 120, '', $author );
Not the ideal solution but it should work. Note that all you’ve really done is increased the default BuddyPress thumb size. As i say, not the ideal approach but i can’t see how you can use
get_avatar()for your objective when BuddyPress filters it in the way it does.
I added this in, and it does get the avatar back but it doesn’t solve the problem. My original code returns the same stretched pixelated avatar, I really need to try and get the large version. See screenshot (mine on top, yours below)
I’m not 100% sure this will resolve the issue but try deleting your avatar and then uploading a new one.
BuddyPress may have ‘crunched’ the image on upload (it may have created a full size image and also a much smaller thumb image). It is possible that it is still serving your old ‘very small’ thumbnail image at the bigger 192×192 size which will account for why it looks like it does.
@applegateian, henries code should work, but as you’ve experienced it won’t change the current size of the avatars. I also believe bp has thumbnail avatars and “full” the smaller “thumbnail” the ones wordpress uses is 50px and the larger(which can be grabbed with bp_core_fetch_avatar) are 150px by 150px.
bp_core_fetch_avatar( array( 'item_id' => $userid, 'type' => 'full', 'width' => 150, 'height' => 150 ));
That will display the “full” avatar.
- The topic ‘Getting the large avatar’ is closed to new replies.