Skip to:
Content
Pages
Categories
Search
Top
Bottom

Getting the large avatar


  • applegateian
    Participant

    @applegateian

    Hi guys

    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>
Viewing 12 replies - 1 through 12 (of 12 total)

  • mattg123
    Participant

    @mattg123

    You’re using wordpress’s get_avatar, bp_core_fetch_avatar is what you’re looking for


    applegateian
    Participant

    @applegateian

    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>

    mattg123
    Participant

    @mattg123

    @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)

    vaytructuyen
    Participant

    @vaytructuyen

    You’re using wordpress’s get_avatar is what you’re looking for


    Henry
    Member

    @henrywright-1

    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.

    https://core.trac.wordpress.org/ticket/24596

    Wonder if anyone thinks it’s worthy of a BP Trac ticket?


    Henry
    Member

    @henrywright-1

    I’ve just raised a BP Trac ticket for this
    https://buddypress.trac.wordpress.org/ticket/5074


    applegateian
    Participant

    @applegateian

    Ah so you think this can’t work as it stands @henrywright-1 ?


    Henry
    Member

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


    applegateian
    Participant

    @applegateian

    Hi there

    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)

    screenshot


    Henry
    Member

    @henrywright-1

    @applegateian

    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.


    mattg123
    Participant

    @mattg123

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


    applegateian
    Participant

    @applegateian

    You’re right @henrywright-1 – just needed to upload the avatars again and it worked 🙂

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Getting the large avatar’ is closed to new replies.
Skip to toolbar