From 33070fb7d2866b0bced6474344fb8683fc09d4d5 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 11 Oct 2020 20:01:06 +0000 Subject: [PATCH] Media: Allow the `gallery_shortcode()` and `get_image_tag()` functions to correctly accept an array of image dimensions. These functions did previously accept an array of image dimensions but their class attributes were not properly constructed. Fixes #51362 Built from https://develop.svn.wordpress.org/trunk@49128 git-svn-id: http://core.svn.wordpress.org/trunk@48890 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 7 ++++--- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index f30b7e14fc..ab33c88c04 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -367,7 +367,7 @@ function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) { * @param string $title Image description for the title attribute. * @param string $align Part of the class name for aligning the image. * @param string|int[] $size Optional. Image size. Accepts any registered image size name, or an array of - * width and height values in pixels (in that order). Default 'medium'. + * width and height values in pixels (in that order). Default 'medium'. * @return string HTML IMG element for given image attachment */ function get_image_tag( $id, $alt, $title, $align, $size = 'medium' ) { @@ -377,7 +377,8 @@ function get_image_tag( $id, $alt, $title, $align, $size = 'medium' ) { $title = $title ? 'title="' . esc_attr( $title ) . '" ' : ''; - $class = 'align' . esc_attr( $align ) . ' size-' . esc_attr( $size ) . ' wp-image-' . $id; + $size_class = is_array( $size ) ? implode( 'x', $size ) : $size; + $class = 'align' . esc_attr( $align ) . ' size-' . esc_attr( $size_class ) . ' wp-image-' . $id; /** * Filters the value of the attachment's image tag class attribute. @@ -2334,7 +2335,7 @@ function gallery_shortcode( $attr ) { \n\t\t"; } - $size_class = sanitize_html_class( $atts['size'] ); + $size_class = sanitize_html_class( is_array( $atts['size'] ) ? implode( 'x', $atts['size'] ) : $atts['size'] ); $gallery_div = "