Make WordPress Core

Ticket #31469: miqro-31469.2.diff

File miqro-31469.2.diff, 5.6 KB (added by miqrogroove, 10 years ago)

Also adds 'extra_attr' arg for inserting more code into avatar element.

  • src/wp-includes/link-template.php

     
    34223422 * @param array $args        {
    34233423 *     Optional. Arguments to return instead of the default arguments.
    34243424 *
    3425  *     @type int    $size           Height and width of the avatar in pixels. Default 96.
     3425 *     @type int    $size           Height and width of the avatar image file in pixels. Default 96.
     3426 *     @type int    $height         Display height of the avatar in pixels. Default 96.
     3427 *     @type int    $width          Display width of the avatar in pixels. Default 96.
    34263428 *     @type string $default        URL for the default image or a default type. Accepts '404' (return
    34273429 *                                  a 404 instead of a default image), 'retro' (8bit), 'monsterid' (monster),
    34283430 *                                  'wavatar' (cartoon face), 'indenticon' (the "quilt"), 'mystery', 'mm',
     
    34363438 *                                  Default null.
    34373439 *     @type array  $processed_args When the function returns, the value will be the processed/sanitized $args
    34383440 *                                  plus a "found_avatar" guess. Pass as a reference. Default null.
     3441 *     @type string $extra_attr     HTML attribute to insert in the IMG element.  Has no default and is not sanitized.
    34393442 * }
    34403443 *
    34413444 * @return array $processed_args {
     
    34493452function get_avatar_data( $id_or_email, $args = null ) {
    34503453        $args = wp_parse_args( $args, array(
    34513454                'size'           => 96,
     3455                'height'         => 96,
     3456                'width'          => 96,
    34523457                'default'        => get_option( 'avatar_default', 'mystery' ),
    34533458                'force_default'  => false,
    34543459                'rating'         => get_option( 'avatar_rating' ),
    34553460                'scheme'         => null,
    34563461                'processed_args' => null, // if used, should be a reference
     3462                'extra_attr'     => '',
    34573463        ) );
    34583464
    34593465        if ( is_numeric( $args['size'] ) ) {
     
    34653471                $args['size'] = 96;
    34663472        }
    34673473
     3474        if ( is_numeric( $args['height'] ) ) {
     3475                $args['height'] = absint( $args['height'] );
     3476                if ( ! $args['height'] ) {
     3477                        $args['height'] = 96;
     3478                }
     3479        } else {
     3480                $args['height'] = 96;
     3481        }
     3482
     3483        if ( is_numeric( $args['width'] ) ) {
     3484                $args['width'] = absint( $args['width'] );
     3485                if ( ! $args['width'] ) {
     3486                        $args['width'] = 96;
     3487                }
     3488        } else {
     3489                $args['width'] = 96;
     3490        }
     3491
    34683492        if ( empty( $args['default'] ) ) {
    34693493                $args['default'] = get_option( 'avatar_default', 'mystery' );
    34703494        }
  • src/wp-includes/pluggable.php

     
    21012101 *
    21022102 * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
    21032103 *                           user email, WP_User object, WP_Post object, or comment object.
    2104  * @param int    $size       Optional. Height and width of the avatar in pixels. Default 96.
     2104 * @param int    $size       Optional. Height and width of the avatar image file in pixels. Default 96.
    21052105 * @param string $default    Optional. URL for the default image or a default type. Accepts '404'
    21062106 *                           (return a 404 instead of a default image), 'retro' (8bit), 'monsterid'
    21072107 *                           (monster), 'wavatar' (cartoon face), 'indenticon' (the "quilt"),
     
    21122112 * @param array  $args       {
    21132113 *     Optional. Extra arguments to retrieve the avatar.
    21142114 *
     2115 *     @type int          $height        Display height of the avatar in pixels. Default 96.
     2116 *     @type int          $width         Display width of the avatar in pixels. Default 96.
    21152117 *     @type bool         $force_default Whether to always show the default image, never the Gravatar. Default false.
    21162118 *     @type string       $rating        What rating to display avatars up to. Accepts 'G', 'PG', 'R', 'X', and are
    21172119 *                                       judged in that order. Default is the value of the 'avatar_rating' option.
     
    21212123 *                                       Default null.
    21222124 *     @type bool         $force_display Whether to always show the avatar - ignores the show_avatars option.
    21232125 *                                       Default false.
     2126 *     @type string       $extra_attr    HTML attribute to insert in the IMG element.  Has no default and is not sanitized.
    21242127 * }
    21252128 *
    21262129 * @return false|string `<img>` tag for the user's avatar. False on failure.
     
    21292132        $defaults = array(
    21302133                // get_avatar_data() args.
    21312134                'size'          => 96,
     2135                'height'        => 96,
     2136                'width'         => 96,
    21322137                'default'       => get_option( 'avatar_default', 'mystery' ),
    21332138                'force_default' => false,
    21342139                'rating'        => get_option( 'avatar_rating' ),
     
    21362141                'alt'           => '',
    21372142                'class'         => null,
    21382143                'force_display' => false,
     2144                'extra_attr'    => '',
    21392145        );
    21402146
    21412147        if ( empty( $args ) ) {
     
    21452151        $args['size']    = $size;
    21462152        $args['default'] = $default;
    21472153        $args['alt']     = $alt;
     2154       
     2155        if ( empty( $args['height'] ) {
     2156                $args['height'] = $size;
     2157        }
     2158        if ( empty( $args['width'] ) {
     2159                $args['width'] = $size;
     2160        }
    21482161
    21492162        $args = wp_parse_args( $args, $defaults );
    21502163
     
    21932206        }
    21942207
    21952208        $avatar = sprintf(
    2196                 "<img alt='%s' src='%s' class='%s' height='%d' width='%d' />",
     2209                "<img alt='%s' src='%s' class='%s' height='%d' width='%d' %s/>",
    21972210                esc_attr( $args['alt'] ),
    21982211                esc_url( $url ),
    21992212                esc_attr( join( ' ', $class ) ),
    2200                 (int) $args['size'],
    2201                 (int) $args['size']
     2213                (int) $args['height'],
     2214                (int) $args['width'],
     2215                $args['extra_attr']
    22022216        );
    22032217
    22042218        /**