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
This commit is contained in:
John Blackbourn 2020-10-11 19:59:15 +00:00
parent f14a2dfbba
commit 564fb09efd

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 $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 ) {
</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}'>";
/**