Skip to:
Content

BuddyPress.org

Changeset 5455


Ignore:
Timestamp:
12/07/2011 02:31:53 AM (13 years ago)
Author:
boonebgorges
Message:

Pass alt and title parameters to bp_core_fetch_avatar() on group directory page, when possible. Fixes alt logic and reduces queries in bp_core_fetch_avatar(). See #3804

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-avatars.php

    r5431 r5455  
    8989    $def_type   = 'thumb';
    9090    $def_class  = 'avatar';
    91     $def_alt    = __( 'Avatar Image', 'buddypress' );
    9291
    9392    // Set the default variables array
     
    101100        'class'      => $def_class,  // Custom <img> class (string)
    102101        'css_id'     => false,       // Custom <img> ID (string)
    103         'alt'        => $def_alt,    // Custom <img> alt (string)
     102        'alt'        => '',          // Custom <img> alt (string)
    104103        'email'      => false,       // Pass the user email (for gravatar) to prevent querying the DB for it
    105104        'no_grav'    => false,       // If there is no avatar found, return false instead of a grav?
     
    148147    $item_name = '';
    149148
    150     if ( 'user' == $object )
    151         $item_name = bp_core_get_user_displayname( $item_id );
    152     elseif ( 'group' == $object )
    153         $item_name = bp_get_group_name( groups_get_group( array( 'group_id' => $item_id ) ) );
    154     elseif ( 'blog' == $object )
    155         $item_name = get_blog_option( $item_id, 'blogname' );
    156 
    157     $alt = sprintf( $alt, apply_filters( 'bp_core_avatar_alt', $item_name, $item_id, $object ) );
     149    // Don't do this query if we don't have to
     150    if ( !$alt || !$title ) {
     151        if ( 'user' == $object )
     152            $item_name = bp_core_get_user_displayname( $item_id );
     153        elseif ( 'group' == $object )
     154            $item_name = bp_get_group_name( groups_get_group( array( 'group_id' => $item_id ) ) );
     155        elseif ( 'blog' == $object )
     156            $item_name = get_blog_option( $item_id, 'blogname' );
     157    }
     158
     159    if ( !$alt && $item_name ) {
     160        $alt = sprintf( __( "Avatar Image: %s", 'buddypress' ), apply_filters( 'bp_core_avatar_alt', $item_name, $item_id, $object ) );
     161    } elseif ( !$alt ) {
     162        $alt = __( 'Avatar Image', 'buddypress' );
     163    }
    158164
    159165    // Set title tag
  • trunk/bp-groups/bp-groups-template.php

    r5431 r5455  
    394394
    395395        /* Fetch the avatar from the folder, if not provide backwards compat. */
    396         if ( !$avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height ) ) )
     396        if ( !$avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'title' => $groups_template->group->name, 'alt' => $groups_template->group->name ) ) )
    397397            $avatar = '<img src="' . esc_attr( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />';
    398398
Note: See TracChangeset for help on using the changeset viewer.