Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/30/2020 10:13:38 PM (15 months ago)
Author:
imath
Message:

Blogs: use a default "blavatar" when the blog has no site icon

So far when the Blogs component was not supporting the WordPress site icon feature or when the blog had no site icon set, we used to fallback on the Blog Administrator's avatar.

We realized this was a wrong approach, because:

  • the site creator may no longer be a member of the specific site, in which case the lowest id will belong to a different (non-admin) user.
  • The site admin may have changed in some other way.
  • The site creator's account may have been deleted.
  • Etc.

When any of these happen, you get the avatar of a random site user.

That's why just like we do for users or groups, we are now using a default blog avatar (mysterious-blog.png) as a fallback when the site icon for the blog is not available.

Props boonebgorges, vapvarun, johnjamesjacoby

Fixes #8179

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/bp-blogs-filters.php

    r12173 r12772  
    138138
    139139/**
     140 * Use the mystery blog avatar for blogs.
     141 *
     142 * @since 7.0.0
     143 *
     144 * @param string $avatar Current avatar src.
     145 * @param array  $params Avatar params.
     146 * @return string
     147 */
     148function bp_blogs_default_avatar( $avatar, $params ) {
     149    if ( isset( $params['object'] ) && 'blog' === $params['object'] ) {
     150        if ( isset( $params['type'] ) && 'thumb' === $params['type'] ) {
     151            $file = 'mystery-blog-50.png';
     152        } else {
     153            $file = 'mystery-blog.png';
     154        }
     155
     156        $avatar = buddypress()->plugin_url . "bp-core/images/$file";
     157    }
     158
     159    return $avatar;
     160}
     161add_filter( 'bp_core_avatar_default',       'bp_blogs_default_avatar', 10, 2 );
     162add_filter( 'bp_core_avatar_default_thumb', 'bp_blogs_default_avatar', 10, 2 );
     163
     164/**
    140165 * Filters the column name during blog metadata queries.
    141166 *
Note: See TracChangeset for help on using the changeset viewer.