diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index 7db8f285e2..3a4627d56a 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -3422,7 +3422,9 @@ function get_avatar_url( $id_or_email, $args = null ) {
* @param array $args {
* Optional. Arguments to return instead of the default arguments.
*
- * @type int $size Height and width of the avatar in pixels. Default 96.
+ * @type int $size Height and width of the avatar image file in pixels. Default 96.
+ * @type int $height Display height of the avatar in pixels. Defaults to $size.
+ * @type int $width Display width of the avatar in pixels. Defaults to $size.
* @type string $default URL for the default image or a default type. Accepts '404' (return
* a 404 instead of a default image), 'retro' (8bit), 'monsterid' (monster),
* 'wavatar' (cartoon face), 'indenticon' (the "quilt"), 'mystery', 'mm',
@@ -3436,6 +3438,7 @@ function get_avatar_url( $id_or_email, $args = null ) {
* Default null.
* @type array $processed_args When the function returns, the value will be the processed/sanitized $args
* plus a "found_avatar" guess. Pass as a reference. Default null.
+ * @type string $extra_attr HTML attribute to insert in the IMG element. Has no default and is not sanitized.
* }
*
* @return array $processed_args {
@@ -3449,11 +3452,14 @@ function get_avatar_url( $id_or_email, $args = null ) {
function get_avatar_data( $id_or_email, $args = null ) {
$args = wp_parse_args( $args, array(
'size' => 96,
+ 'height' => null,
+ 'width' => null,
'default' => get_option( 'avatar_default', 'mystery' ),
'force_default' => false,
'rating' => get_option( 'avatar_rating' ),
'scheme' => null,
'processed_args' => null, // if used, should be a reference
+ 'extra_attr' => '',
) );
if ( is_numeric( $args['size'] ) ) {
@@ -3465,6 +3471,24 @@ function get_avatar_data( $id_or_email, $args = null ) {
$args['size'] = 96;
}
+ if ( is_numeric( $args['height'] ) ) {
+ $args['height'] = absint( $args['height'] );
+ if ( ! $args['height'] ) {
+ $args['height'] = $args['size'];
+ }
+ } else {
+ $args['height'] = $args['size'];
+ }
+
+ if ( is_numeric( $args['width'] ) ) {
+ $args['width'] = absint( $args['width'] );
+ if ( ! $args['width'] ) {
+ $args['width'] = $args['size'];
+ }
+ } else {
+ $args['width'] = $args['size'];
+ }
+
if ( empty( $args['default'] ) ) {
$args['default'] = get_option( 'avatar_default', 'mystery' );
}
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index 0fe8ab820d..4eae503d7e 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -2101,7 +2101,7 @@ if ( !function_exists( 'get_avatar' ) ) :
*
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
* user email, WP_User object, WP_Post object, or comment object.
- * @param int $size Optional. Height and width of the avatar in pixels. Default 96.
+ * @param int $size Optional. Height and width of the avatar image file in pixels. Default 96.
* @param string $default Optional. URL for the default image or a default type. Accepts '404'
* (return a 404 instead of a default image), 'retro' (8bit), 'monsterid'
* (monster), 'wavatar' (cartoon face), 'indenticon' (the "quilt"),
@@ -2112,6 +2112,8 @@ if ( !function_exists( 'get_avatar' ) ) :
* @param array $args {
* Optional. Extra arguments to retrieve the avatar.
*
+ * @type int $height Display height of the avatar in pixels. Defaults to $size.
+ * @type int $width Display width of the avatar in pixels. Defaults to $size.
* @type bool $force_default Whether to always show the default image, never the Gravatar. Default false.
* @type string $rating What rating to display avatars up to. Accepts 'G', 'PG', 'R', 'X', and are
* judged in that order. Default is the value of the 'avatar_rating' option.
@@ -2121,6 +2123,7 @@ if ( !function_exists( 'get_avatar' ) ) :
* Default null.
* @type bool $force_display Whether to always show the avatar - ignores the show_avatars option.
* Default false.
+ * @type string $extra_attr HTML attribute to insert in the IMG element. Has no default and is not sanitized.
* }
*
* @return false|string `` tag for the user's avatar. False on failure.
@@ -2129,6 +2132,8 @@ function get_avatar( $id_or_email, $size = 96, $default = '', $alt = '', $args =
$defaults = array(
// get_avatar_data() args.
'size' => 96,
+ 'height' => null,
+ 'width' => null,
'default' => get_option( 'avatar_default', 'mystery' ),
'force_default' => false,
'rating' => get_option( 'avatar_rating' ),
@@ -2136,6 +2141,7 @@ function get_avatar( $id_or_email, $size = 96, $default = '', $alt = '', $args =
'alt' => '',
'class' => null,
'force_display' => false,
+ 'extra_attr' => '',
);
if ( empty( $args ) ) {
@@ -2148,6 +2154,13 @@ function get_avatar( $id_or_email, $size = 96, $default = '', $alt = '', $args =
$args = wp_parse_args( $args, $defaults );
+ if ( empty( $args['height'] ) ) {
+ $args['height'] = $args['size'];
+ }
+ if ( empty( $args['width'] ) ) {
+ $args['width'] = $args['size'];
+ }
+
/**
* Filter whether to retrieve the avatar URL early.
*
@@ -2193,12 +2206,13 @@ function get_avatar( $id_or_email, $size = 96, $default = '', $alt = '', $args =
}
$avatar = sprintf(
- "",
+ "",
esc_attr( $args['alt'] ),
esc_url( $url ),
esc_attr( join( ' ', $class ) ),
- (int) $args['size'],
- (int) $args['size']
+ (int) $args['height'],
+ (int) $args['width'],
+ $args['extra_attr']
);
/**
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 612040b106..32f4175bbb 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
-$wp_version = '4.2-alpha-31560';
+$wp_version = '4.2-alpha-31561';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.