Skip to:
Content

BuddyPress.org

Ticket #2606: 2606.patch

File 2606.patch, 7.5 KB (added by DJPaul, 15 years ago)

v1

  • bp-core/bp-core-filters.php

     
    222222if ( !is_admin() || ( is_admin() && empty( $_POST['noconfirmation'] ) ) )
    223223        add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_notification', 1, 4 );
    224224
     225add_filter( 'bp_core_avatar_alt', 'wp_filter_kses', 1 );
     226add_filter( 'bp_core_avatar_alt', 'wptexturize' );
     227add_filter( 'bp_core_avatar_alt', 'convert_chars' );
     228add_filter( 'bp_core_avatar_alt', 'stripslashes_deep' );
    225229?>
     230 No newline at end of file
  • bp-core/bp-core-templatetags.php

     
    311311                        'height' => false,
    312312                        'class' => 'avatar',
    313313                        'id' => false,
    314                         'alt' => __( 'Member avatar', 'buddypress' )
     314                        'alt' => __( 'Picture of %s', 'buddypress' )
    315315                );
    316316
    317317                $r = wp_parse_args( $args, $defaults );
     
    686686                        'type'          => 'thumb',
    687687                        'width'         => false,
    688688                        'height'        => false,
    689                         'html'          => true
     689                        'html'          => true,
     690                        'alt' => __( 'Picture of %s', 'buddypress' )
    690691                );
    691692
    692693                $r = wp_parse_args( $args, $defaults );
    693694                extract( $r, EXTR_SKIP );
    694695
    695                 return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html ) ) );
     696                return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
    696697        }
    697698
    698699function bp_displayed_user_avatar( $args = '' ) {
     
    705706                        'type'          => 'thumb',
    706707                        'width'         => false,
    707708                        'height'        => false,
    708                         'html'          => true
     709                        'html'          => true,
     710                        'alt' => __( 'Picture of %s', 'buddypress' )
    709711                );
    710712
    711713                $r = wp_parse_args( $args, $defaults );
    712714                extract( $r, EXTR_SKIP );
    713715
    714                 return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html ) ) );
     716                return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
    715717        }
    716718
    717719function bp_avatar_admin_step() {
  • bp-core/bp-core-avatars.php

     
    5252 * Fetches an avatar from a BuddyPress object. Supports user/group/blog as
    5353 * default, but can be extended to include your own custom components too.
    5454 *
    55  * @global object $bp
    56  * @global object $current_blog
     55 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     56 * @global $current_blog WordPress global containing information and settings for the current blog being viewed.
     57 * @global $members_template Members/Group Members template loop object
    5758 * @param array $args Determine the output of this function
    5859 * @return string Formatted HTML <img> element, or raw avatar URL based on $html arg
    5960 */
    6061function bp_core_fetch_avatar( $args = '' ) {
    61         global $bp, $current_blog;
     62        global $bp, $current_blog, $members_template;
    6263
    6364        // Set a few default variables
    6465        $def_object             = 'user';
     
    7980                'alt'                   => $def_alt,    // Custom <img> alt (string)
    8081                'email'                 => false,               // Pass the user email (for gravatar) to prevent querying the DB for it
    8182                'no_grav'               => false,               // If there is no avatar found, return false instead of a grav?
    82                 'html'                  => true                 // Wrap the return img URL in <img />
     83                'html'                  => true,                // Wrap the return img URL in <img />
     84                'title'                 => ''                   // Custom <img> title (string)
    8385        );
    8486
    8587        // Compare defaults to passed and extract
     
    117119        // Add an identifying class to each item
    118120        $class .= ' ' . $object . '-' . $item_id . '-avatar';
    119121
     122        // Set alt tag
     123        $item_name = '';
     124
     125        if ( 'user' == $object ) {
     126                if ( $members_template->member )
     127                        $item_name = bp_get_member_name();
     128                else
     129                        $item_name = bp_core_get_user_displayname( $item_id );
     130        } elseif ( 'group' == $object ) {
     131                $item_name = bp_get_group_name();
     132        } elseif ( 'blog' == $object ) {
     133                $item_name = bp_get_blog_name();
     134        }
     135
     136        $alt = sprintf( $alt, esc_attr( apply_filters( 'bp_core_avatar_alt', $item_name, $item_id, $object ) ) );
     137
     138        // Set title tag
     139        if ( $title )
     140                $title = " title='" . esc_attr( apply_filters( 'bp_core_avatar_title', $title ) ) . "'";
     141        elseif ( $item_name )
     142                $title = " title='" . esc_attr( apply_filters( 'bp_core_avatar_title', $item_name, $item_id, $object ) ) . "'";
     143
    120144        // Set CSS ID if passed
    121145        if ( !empty( $css_id ) )
    122146                $css_id = " id='{$css_id}'";
     
    195219
    196220                        // Return it wrapped in an <img> element
    197221                        if ( true === $html ) {
    198                                 return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
     222                                return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
    199223
    200224                        // ...or only the URL
    201225                        } else {
     
    246270
    247271                // Return gravatar wrapped in <img />
    248272                if ( true === $html )
    249                         return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $gravatar . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
     273                        return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $gravatar . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
    250274
    251275                // ...or only return the gravatar URL
    252276                else
     
    499523        if ( empty( $id ) )
    500524                return !empty( $avatar ) ? $avatar : $default;
    501525
     526        if ( !$alt )
     527                $alt = __( 'Picture of %s', 'buddypress' );
     528
    502529        // Let BuddyPress handle the fetching of the avatar
    503530        $bp_avatar = bp_core_fetch_avatar( array( 'item_id' => $id, 'width' => $size, 'height' => $size, 'alt' => $alt ) );
    504531
  • bp-blogs/bp-blogs-templatetags.php

     
    192192                        'height' => false,
    193193                        'class' => 'avatar',
    194194                        'id' => false,
    195                         'alt' => __( 'Blog avatar', 'buddypress' ),
     195                        'alt' => __( 'Avatar of blog %s', 'buddypress' ),
    196196                        'no_grav' => true
    197197                );
    198198
  • bp-groups/bp-groups-templatetags.php

     
    279279                        'height' => false,
    280280                        'class' => 'avatar',
    281281                        'id' => false,
    282                         'alt' => __( 'Group avatar', 'buddypress' )
     282                        'alt' => __( 'Avatar of group %s', 'buddypress' )
    283283                );
    284284
    285285                $r = wp_parse_args( $args, $defaults );