Skip to:
Content

BuddyPress.org

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#5454 closed defect (bug) (duplicate)

BuddyPress Groups should gracefully handle the case where show_avatars is false

Reported by: jjeaton Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch needs-testing
Cc:

Description

I recently ran into an issue where a site had show_avatars disabled, and BuddyPress group avatars were broken on the single group and group archive pages.

Instead of completely removing the image markup, an img tag is output with a missing src attribute, and another image tag (the default 'no avatar' image) is output as the first child of the body element, along with breaking the <head> section.

Missing img tag with missing src:

<img src="" class="avatar" alt="Test Group">

Broken head and image at top of body:

<html lang="en-US">
<head></head>
<body class="single-item groups logged-in group-home home buddypress admin-bar masthead-fixed full-width singular js customize-support">
  <img src="/none.gif" alt="No Group Avatar" class="avatar">
  <!-- the rest of the <head> tags end up here -->

Members do not have the same issue. When show_avatars is disabled, the image is not included in the markup.

I believe the issue is in bp_get_group_avatar in bp-groups-template.php: https://buddypress.trac.wordpress.org/browser/trunk/bp-groups/bp-groups-template.php#L509. If show_avatars is false, bp_core_fetch_avatar returns nothing, and bp_get_group_avatar falls to backwards compatibility and tries to access properties on the group object that no longer exist.

I tested this on a fresh installation of WP 3.8.1, the twentyfourteen theme, and BuddyPress 1.9.2.

Attachments (1)

5454.patch (1.4 KB) - added by jjeaton 6 years ago.

Download all attachments as: .zip

Change History (6)

@jjeaton
6 years ago

#1 @jjeaton
6 years ago

  • Keywords has-patch needs-testing added

It seems the issue here is the backwards compat. that bp_get_group_avatar uses if the avatar doesn't exist. I've created a patch that only uses the backwards compat. code if that property exists on the group object, otherwise it returns nothing just like members do. This fixes the issue for me.

We could also have this display the BuddyPress default avatar, but since members is already doing it this way, I assume that's the recommended approach.

#2 @imath
6 years ago

  • Keywords reporter-feedback added

Hi jjeaton

Thanks for your feedback, i've also worked on a patch about it, do you think the patch i've made could also reply to this ticket ?

see #5345

#3 @DJPaul
6 years ago

  • Milestone changed from Awaiting Review to 2.1

In 2.1, it would be great if someone can merge these patches and close down one of the tickets.

#4 @jjeaton
6 years ago

  • Keywords reporter-feedback removed
  • Milestone 2.1 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

I searched all over and couldn't find your ticket. Looks like mine is a duplicate. I'll close in favor of #5345.

#5 @DJPaul
3 years ago

  • Component changed from API - Avatars to Media
Note: See TracTickets for help on using tickets.