WordPress.org

Make WordPress Core

Ticket #37773: patch.diff

File patch.diff, 1.7 KB (added by jmichaelward, 4 years ago)
  • wp-includes/pluggable.php

     
    22372237 *
    22382238 * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
    22392239 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
    2240  * @param int    $size       Optional. Height and width of the avatar image file in pixels. Default 96.
     2240 * @param int|string $size   Optional. Height and width of the avatar image file in pixels. Default 96.
    22412241 * @param string $default    Optional. URL for the default image or a default type. Accepts '404'
    22422242 *                           (return a 404 instead of a default image), 'retro' (8bit), 'monsterid'
    22432243 *                           (monster), 'wavatar' (cartoon face), 'indenticon' (the "quilt"),
     
    22642264 * @return false|string `<img>` tag for the user's avatar. False on failure.
    22652265 */
    22662266function get_avatar( $id_or_email, $size = 96, $default = '', $alt = '', $args = null ) {
     2267        // Check first for native WordPress image sizes.
     2268        if ( is_string( $size ) && in_array( $size, get_intermediate_image_sizes() ) ) {
     2269                $dimensions = array(
     2270                        'height' => get_option( "{$size}_size_h" ),
     2271                        'width'  => get_option( "{$size}_size_w" ),
     2272                );
     2273
     2274                $size = (int) $dimensions['height'] > $dimensions['width'] ? $dimensions['height'] : $dimensions['width'];
     2275        }
     2276
    22672277        $defaults = array(
    22682278                // get_avatar_data() args.
    2269                 'size'          => 96,
     2279                'size'          => $size,
    22702280                'height'        => null,
    22712281                'width'         => null,
    22722282                'default'       => get_option( 'avatar_default', 'mystery' ),