Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/09/2011 01:17:57 AM (15 years ago)
Author:
boonebgorges
Message:

Deemphasizes sprintf() type 'alt' parameters for bp_core_fetch_avatar(), in order to avoid unnecessary database queries when loading avatars. Modifies calls throughout bp_core_fetch_avatar() so that they pass literal strings as 'alt' parameters. See #3806

File:
1 edited

Legend:

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

    r5455 r5466  
    146146        // Get item name for alt/title tags
    147147        $item_name = '';
    148 
    149         // Don't do this query if we don't have to
    150         if ( !$alt || !$title ) {
     148       
     149        // Backpat for the 'alt' parameter, which used to encourage sprintf()-style values
     150        if ( false !== strpos( $alt, '%s' ) || false !== strpos( $alt, '%1$s' ) ) {
     151                var_dump( 'yes' );
    151152                if ( 'user' == $object )
    152153                        $item_name = bp_core_get_user_displayname( $item_id );
    … …  
    155156                elseif ( 'blog' == $object )
    156157                        $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 ) {
     158               
     159                $alt = sprintf( $alt, apply_filters( 'bp_core_avatar_alt', $item_name, $item_id, $object ) );
     160        }
     161
     162        // Get a fallback for the 'alt' parameter       
     163        if ( !$alt ) {
    162164                $alt = __( 'Avatar Image', 'buddypress' );
    163165        }
    164166
    165         // Set title tag
     167        // Set title tag, if it's been provided
    166168        if ( $title )
    167169                $title = " title='" . esc_attr( apply_filters( 'bp_core_avatar_title', $title, $item_id, $object ) ) . "'";
    168         elseif ( $item_name )
    169                 $title = " title='" . esc_attr( apply_filters( 'bp_core_avatar_title', $item_name, $item_id, $object ) ) . "'";
    170170
    171171        // Set CSS ID if passed
Note: See TracChangeset for help on using the changeset viewer.