Skip to:
Content
Pages
Categories
Search
Top
Bottom

Changing Avatar size sometimes creates Fuzzy Avatars

Viewing 8 replies - 1 through 8 (of 8 total)
  • @sbrajesh

    Participant

    Did you make changes in bp-custom.php using the

    define( 'BP_AVATAR_THUMB_WIDTH', 105 )

    If yes, then It will work perfectly for the newly uploaded avatars after you made the changes, but the avatars which were uploaded before you made change will be distorted. User will need to reupload them.

    @jordashtalon

    Member

    What about other places where I want the width to be 50×50? some areas i want the Avatar to be 50×50 and others i want it 105×105 I guess shrinking the Avatar isn’t a problem.

    @sbrajesh

    Participant

    well, The very first thing is
    1. define the 2 size(bp allows only 3 sizes of avatar at this moment) using the constants BP_AVATAR_(THUMB/FULL/ORIGINAL_MAX)_HEIGHT and BP_AVATAR_(THUMB/FULL/ORIGINAL_MAX)_WIDTH if the original avatar sizes(50×50,150×150,450×450) does not fit your requirement.

    Then use bp_core_fetch_avatar, it supports the width,height property and thumb type
    You can fetch an avatar of different size using different width/height value but again, It will not crop, it will constrain the avar using the width/height property in the img tag. so i don’t think it will be of much use .

    But if you want only 2 sizes of avatar, as you mentioned above, define one as Thumb,other as full and fetch thumb using “type=thumb” and the other using “type=anything other than thumb” in bp_core_fetch_avatar and it will work.

    @crashutah

    Participant

    @sbrajesh It seems like the group avatar’s use this same code. How would you call the bp_core_fetch_avatar of varying sizes for groups by group id?

    @sbrajesh

    Participant

    @crashutah
    That’s a good point. Incase we want different size for groups and members the only good way is to override the “bp_core_avatar_handle_crop” and may be in extreme case “bp_core_avatar_handle_upload” and that will give you enormous flexibility.
    After overriding it, we can filter on “bp_core_fetch_avatar” and that will be all we need.

    @sbrajesh

    Participant

    btw, if you are not concerned about the aspect ratio, you can simply pass width and height(I guess you already know about it :) )

    @crashutah

    Participant

    I’ve been trying to get it to pull various size group avatars and haven’t had much luck. Here’s the code I’m using:
    $avatar = bp_core_fetch_avatar( array( ‘item_id’ => $group->id, ‘object’ => ‘group’, ‘type’ => $type, ‘avatar_dir’ => ‘group-avatars’, ‘alt’ => $alt, ‘css_id’ => $id, ‘class’ => $class, ‘width’ => $width, ‘height’ => $height ) );

    Shouldn’t I just be able to pass the width and height values that I want? Am I only allowed to pass in certain width and height values? Seems like I could also pass in $type and that could give me the various sizes?

    Also, this passes the full HTML for the image. Is there a way I could just get the URL of the image? I could rip it out of the HTML, but that’s kind of messy.

    @crashutah

    Participant

    So, I haven’t figured all of bp_core_fetch_avatar() out, but here’s some of the types:
    type=thumb
    type=full

    Interestingly, the code I pasted in my previous post took the thumbnail image, but displayed it the size of the full (150×150 I think). So, it was pixelated and ugly. So, I changed it to type=full and it’s a nice 150×150 image.

    If anyone else can explain the rest, this seems like some good content for the codex.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Changing Avatar size sometimes creates Fuzzy Avatars’ is closed to new replies.
Skip to toolbar