WordPress.org

Make WordPress Core

Ticket #7536: better-avatar-alt.diff

File better-avatar-alt.diff, 1.6 KB (added by nbachiyski, 7 years ago)
  • wp-includes/pluggable.php

     
    13441344 * @param int|string|object $id_or_email A user ID,  email address, or comment object 
    13451345 * @param int $size Size of the avatar image 
    13461346 * @param string $default URL to a default image to use if no avatar is available 
    1347  * @param string $alt Alternate text to use in image tag 
     1347 * @param string $alt Alternate text to use in image tag, the default is Avatar 
    13481348 * @return string <img> tag for the user's avatar 
    13491349*/ 
    1350 function get_avatar( $id_or_email, $size = '96', $default = '', $alt = 'Avatar' ) { 
     1350function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) { 
    13511351        if ( ! get_option('show_avatars') ) 
    13521352                return false; 
    13531353 
     1354        if ( false === $alt) 
     1355                $alt = __( 'Avatar' ); 
     1356 
     1357        $safe_alt = attribute_escape( $alt ); 
     1358 
    13541359        if ( !is_numeric($size) ) 
    13551360                $size = '96'; 
    13561361 
     
    14041409                if ( !empty( $rating ) ) 
    14051410                        $out .= "&amp;r={$rating}"; 
    14061411 
    1407                 $avatar = "<img alt='{$alt}' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />"; 
     1412                $avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />"; 
    14081413        } else { 
    1409                 $avatar = "<img alt='{$alt}' src='{$default}' class='avatar avatar-{$size} avatar-default' height='{$size}' width='{$size}' />"; 
     1414                $avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} avatar-default' height='{$size}' width='{$size}' />"; 
    14101415        } 
    14111416 
    14121417        return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);