Skip to:
Content

BuddyPress.org

Changeset 5466


Ignore:
Timestamp:
12/09/2011 01:17:57 AM (13 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

Location:
trunk
Files:
5 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
  • trunk/bp-members/bp-members-adminbar.php

    r5346 r5466  
    3333            'email'   => $bp->loggedin_user->userdata->user_email,
    3434            'width'   => 16,
    35             'height'  => 16
     35            'height'  => 16,
     36            'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_loggedin_user_fullname() )
    3637        ) );
    3738
     
    112113        'email'   => $bp->displayed_user->userdata->user_email,
    113114        'width'   => 16,
    114         'height'  => 16
     115        'height'  => 16,
     116        'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
    115117    ) );
    116118
  • trunk/bp-members/bp-members-buddybar.php

    r5307 r5466  
    7070            echo '<li>';
    7171            echo '<a href="' . bp_core_get_user_domain( $author->user_id, $author->user_nicename, $author->user_login ) . '">';
    72             echo bp_core_fetch_avatar( array( 'item_id' => $author->user_id, 'email' => $author->user_email, 'width' => 15, 'height' => 15 ) ) ;
     72            echo bp_core_fetch_avatar( array(
     73                'item_id' => $author->user_id,
     74                'email'   => $author->user_email,
     75                'width'   => 15,
     76                'height'  => 15,
     77                'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), $author->display_name )
     78            ) );
    7379            echo ' ' . $author->display_name . '</a>';
    7480            echo '<div class="admin-bar-clear"></div>';
  • trunk/bp-members/bp-members-loader.php

    r5412 r5466  
    179179            $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    180180                'item_id' => bp_displayed_user_id(),
    181                 'type'    => 'thumb'
     181                'type'    => 'thumb',
     182                'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
    182183            ) );
    183184            $bp->bp_options_title  = $bp->displayed_user->fullname;
  • trunk/bp-members/bp-members-template.php

    r5458 r5466  
    480480            'class' => 'avatar',
    481481            'id' => false,
    482             'alt' => __( 'Profile picture of %s', 'buddypress' )
     482            'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $members_template->member->fullname )
    483483        );
    484484
     
    776776            'height' => false,
    777777            'html'   => true,
    778             'alt'    => __( 'Profile picture of %s', 'buddypress' )
     778            'alt'    => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_loggedin_user_fullname() )
    779779        );
    780780
     
    796796            'height' => false,
    797797            'html'   => true,
    798             'alt'    => __( 'Profile picture of %s', 'buddypress' )
     798            'alt'    => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
    799799        );
    800800
Note: See TracChangeset for help on using the changeset viewer.