Skip to:
Content

BuddyPress.org

Changeset 6684


Ignore:
Timestamp:
12/28/2012 05:21:31 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Fix bug in bp_get_activity_avatar() causing incorrect alternate avatar text in activity stream comments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-template.php

    r6624 r6684  
    958958     */
    959959    function bp_get_activity_avatar( $args = '' ) {
    960         global $activities_template, $bp;
     960        global $activities_template;
     961
     962        $bp = buddypress();
    961963
    962964        // On activity permalink pages, default to the full-size avatar
    963965        $type_default = bp_is_single_activity() ? 'full' : 'thumb';
    964966
    965         if ( !empty( $activities_template->activity->display_name ) ) {
    966             $dn_default = $activities_template->activity->display_name;
    967         } else if ( !empty( $activities_template->current_comment->display_name ) ) {
    968             $dn_default = $activities_template->current_comment->display_name;
    969         }
    970 
    971         $alt_default = isset( $dn_default ) ? sprintf( __( 'Profile picture of %s', 'buddypress' ), $activities_template->activity->display_name ) : __( 'Profile picture', 'buddypress' );
     967        // Within the activity comment loop, the current activity should be set
     968        // to current_comment. Otherwise, just use activity.
     969        $current_activity_item = isset( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : $activities_template->activity;
     970
     971        // Activity user display name
     972        $dn_default  = isset( $current_activity_item->display_name ) ? $current_activity_item->display_name : '';
     973
     974        // Prepend some descriptive text to alt
     975        $alt_default = !empty( $dn_default ) ? sprintf( __( 'Profile picture of %s', 'buddypress' ), $dn_default ) : __( 'Profile picture', 'buddypress' );
    972976
    973977        $defaults = array(
     
    983987
    984988        if ( !isset( $height ) && !isset( $width ) ) {
     989
    985990            // Backpat
    986991            if ( isset( $bp->avatar->full->height ) || isset( $bp->avatar->thumb->height ) ) {
     
    9961001                $width = 20;
    9971002            }
    998 
    9991003        }
    1000 
    1001         // Within the loop, we the current activity should be set first to the
    1002         // current_comment, if available
    1003         $current_activity_item = isset( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : $activities_template->activity;
    10041004
    10051005        // Primary activity avatar is always a user, but can be modified via a filter
    10061006        $object  = apply_filters( 'bp_get_activity_avatar_object_' . $current_activity_item->component, 'user' );
    1007         $item_id = $user_id ? $user_id : $current_activity_item->user_id;
     1007        $item_id = !empty( $user_id ) ? $user_id : $current_activity_item->user_id;
    10081008        $item_id = apply_filters( 'bp_get_activity_avatar_item_id', $item_id );
    10091009
    10101010        // If this is a user object pass the users' email address for Gravatar so we don't have to refetch it.
    1011         if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $activities_template->activity->user_email ) )
     1011        if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) )
    10121012            $email = $current_activity_item->user_email;
    10131013
    1014         return apply_filters( 'bp_get_activity_avatar', bp_core_fetch_avatar( array( 'item_id' => $item_id, 'object' => $object, 'type' => $type, 'alt' => $alt, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $email ) ) );
     1014        return apply_filters( 'bp_get_activity_avatar', bp_core_fetch_avatar( array(
     1015            'item_id' => $item_id,
     1016            'object'  => $object,
     1017            'type'    => $type,
     1018            'alt'     => $alt,
     1019            'class'   => $class,
     1020            'width'   => $width,
     1021            'height'  => $height,
     1022            'email'   => $email
     1023        ) ) );
    10151024    }
    10161025
Note: See TracChangeset for help on using the changeset viewer.