Skip to:
Content

BuddyPress.org

Changeset 7745


Ignore:
Timestamp:
01/21/2014 12:16:37 AM (11 years ago)
Author:
imath
Message:

On single group screens, uses default avatar as a fallback in group navigation menu

In case the WordPress Discussion Avatar display setting is disabled, using bp_group_current_avatar() to set group navigation menu was outputing an unfound image making the group edit screens unavailable. This fix uses default avatar as a fallback if no group avatar has been found to build the group navigation menu. It also keeps bp_group_current_avatar() function in case it is still used by a plugin or a theme, but this function now outputs the current avatar.

Fixes #5343

Location:
trunk/bp-groups
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-loader.php

    r7520 r7745  
    592592
    593593                if ( empty( $bp->bp_options_avatar ) ) {
    594                     $bp->bp_options_avatar = bp_group_current_avatar();
     594                    $bp->bp_options_avatar = '<img src="' . esc_url( bp_core_avatar_default_thumb() ) . '" alt="' . esc_attr__( 'No Group Avatar', 'buddypress' ) . '" class="avatar" />';
    595595                }
    596596            }
  • trunk/bp-groups/bp-groups-template.php

    r7520 r7745  
    26272627 **/
    26282628
    2629 function bp_group_current_avatar() {
    2630     global $bp;
    2631 
    2632     if ( $bp->groups->current_group->avatar_full ) { ?>
    2633 
    2634         <img src="<?php echo esc_url( $bp->groups->current_group->avatar_full ); ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
    2635 
    2636     <?php } else { ?>
    2637 
    2638         <img src="<?php echo esc_url( $bp->groups->image_base . '/none.gif' ); ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" />
    2639 
    2640     <?php }
    2641 }
     2629/**
     2630 * Outputs the current group avatar
     2631 *
     2632 * @since BuddyPress (1.0)
     2633 * @param string $type thumb or full ?
     2634 * @uses bp_get_group_current_avatar() to get the avatar of the current group
     2635 */
     2636function bp_group_current_avatar( $type = 'thumb' ) {
     2637    echo bp_get_group_current_avatar( $type );
     2638}
     2639   
     2640    /**
     2641     * Returns the current group avatar
     2642     *
     2643     * @since BuddyPress (2.0)
     2644     * @param string $type thumb or full ?
     2645     * @uses bp_core_fetch_avatar() to get the avatar of the group
     2646     * @uses bp_get_current_group_id() to get current group id
     2647     * @uses apply_filters() Filter bp_get_group_current_avatar to modify return value
     2648     * @return string $tab The current tab's slug
     2649     */
     2650    function bp_get_group_current_avatar( $type = 'thumb' ) {
     2651
     2652        $group_avatar = bp_core_fetch_avatar( array(
     2653            'item_id'    => bp_get_current_group_id(),
     2654            'object'     => 'group',
     2655            'type'       => $type,
     2656            'avatar_dir' => 'group-avatars',
     2657            'alt'        => __( 'Group avatar', 'buddypress' ),
     2658            'class'      => 'avatar'
     2659        ) );
     2660
     2661        return apply_filters( 'bp_get_group_current_avatar', $group_avatar );
     2662    }
    26422663
    26432664function bp_get_group_has_avatar() {
Note: See TracChangeset for help on using the changeset viewer.