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
This commit is contained in:
John Blackbourn 2020-10-11 20:01:06 +00:00
parent e11accb411
commit 33070fb7d2
2 changed files with 5 additions and 4 deletions

View File

@ -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 $title Image description for the title attribute.
* @param string $align Part of the class name for aligning the image. * @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 * @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 * @return string HTML IMG element for given image attachment
*/ */
function get_image_tag( $id, $alt, $title, $align, $size = 'medium' ) { 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 ) . '" ' : ''; $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. * Filters the value of the attachment's image tag class attribute.
@ -2334,7 +2335,7 @@ function gallery_shortcode( $attr ) {
</style>\n\t\t"; </style>\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 = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>"; $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
/** /**

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.6-alpha-49127'; $wp_version = '5.6-alpha-49128';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.