Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/27/2016 03:59:26 PM (9 years ago)
Author:
boonebgorges
Message:

Introduce 'mystery group' avatar for groups without custom avatar.

This nifty new image is totally grouperiffic, and it's gonna supercharge
your BuddyPress community, to the extreme.

As part of the improvement, Gravatar requests for group avatars have been
disabled by default. Gravatar requests never match for groups, anyway, so
this should save HTTP requests in most cases. Filter 'bp_core_fetch_avatar_no_grav'
to restore the previous behavior.

Props sooskriszta, abweb.
Fixes #6372.

File:
1 edited

Legend:

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

    r10572 r10721  
    7373// Activity component integration.
    7474add_filter( 'bp_activity_at_name_do_notifications', 'bp_groups_disable_at_mention_notification_for_non_public_groups', 10, 4 );
     75
     76// Default group avatar.
     77add_filter( 'bp_core_avatar_default',       'bp_groups_default_avatar', 10, 3 );
     78add_filter( 'bp_core_avatar_default_thumb', 'bp_groups_default_avatar', 10, 3 );
    7579
    7680/**
     
    320324    return $send;
    321325}
     326
     327/**
     328 * Use the mystery group avatar for groups.
     329 *
     330 * @since 2.6.0
     331 *
     332 * @param string $avatar Current avatar src.
     333 * @param array  $params Avatar params.
     334 * @return string
     335 */
     336function bp_groups_default_avatar( $avatar, $params ) {
     337    if ( isset( $params['object'] ) && 'group' === $params['object'] ) {
     338        if ( isset( $params['type'] ) && 'thumb' === $params['type'] ) {
     339            $file = 'mystery-group-50.png';
     340        } else {
     341            $file = 'mystery-group.png';
     342        }
     343
     344        $avatar = buddypress()->plugin_url . "bp-core/images/$file";
     345    }
     346
     347    return $avatar;
     348}
Note: See TracChangeset for help on using the changeset viewer.