Skip to:
Content

Opened 10 months ago

Closed 5 months ago

#5074 closed defect (bug) (fixed)

get_avatar() filtered by bp_core_fetch_avatar_filter() may result in stretched BP avatar

Reported by: henrywright Owned by: boonebgorges
Milestone: 1.9 Priority: normal
Severity: normal Version: 1.1
Component: Core Keywords:
Cc:

Description

bp_core_fetch_avatar_filter() filters the get_avatar() function so that BuddyPress can attempt to find a BP avatar if one has been uploaded.

Imagine this scenario:

Set a default avatar height and width in bp-cutom.php

define ( 'BP_AVATAR_THUMB_WIDTH', 40 );

define ( 'BP_AVATAR_THUMB_HEIGHT', 40 );

Then use the get_avatar() function in the loop to display the post author's avatar

$author = get_the_author();
echo get_avatar( get_the_author_meta('ID'), 120, '', $author );

Even though an image 120px x 120px in size is outputted, the 40px x 40px BuddyPress thumb image is being used which results in a stretched avatar being displayed (see attached).

Attachments (1)

avatar.jpg (4.1 KB) - added by henrywright 10 months ago.
avatar

Download all attachments as: .zip

Change History (4)

henrywright10 months ago

avatar

comment:1 r-a-y10 months ago

  • Milestone changed from Awaiting Review to 1.9
  • Version changed from 1.7 to 1.1

We can do a better job of detecting the size passed by get_avatar() and checking it against BP's thumb width and full width values.

Whatever width value is closest is the type we should use in bp_core_fetch_avatar().

Moving to 1.9, but might get pushed to Future Release if there are no patches by then.

comment:2 henrywright10 months ago

Hi r-a-y,

Instead of using type closest in size to the size passed by get_avatar(), perhaps use type full only when the passed size is greater than the thumb size. This will always avoid the stretching seen in the attached pic.

comment:3 boonebgorges5 months ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 7585:

When swapping WP avatars, use 'full' type if requested size is larger than BP thumbs.

This prevents unsightly stretching.

Fixes #5074

Note: See TracTickets for help on using tickets.