From 564fb09efd6da1e1f247ad1132afc5475ff70a01 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 11 Oct 2020 19:59:15 +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 git-svn-id: https://develop.svn.wordpress.org/trunk@49128 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/media.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index f30b7e14fc..ab33c88c04 100644 --- a/src/wp-includes/media.php +++ b/src/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 = "