Make WordPress Core

Changeset 49128


Ignore:
Timestamp:
10/11/2020 07:59:15 PM (4 years ago)
Author:
johnbillion
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r49108 r49128  
    368368 * @param string       $align Part of the class name for aligning the image.
    369369 * @param string|int[] $size  Optional. Image size. Accepts any registered image size name, or an array of
    370  *                           width and height values in pixels (in that order). Default 'medium'.
     370 *                            width and height values in pixels (in that order). Default 'medium'.
    371371 * @return string HTML IMG element for given image attachment
    372372 */
     
    378378    $title = $title ? 'title="' . esc_attr( $title ) . '" ' : '';
    379379
    380     $class = 'align' . esc_attr( $align ) . ' size-' . esc_attr( $size ) . ' wp-image-' . $id;
     380    $size_class = is_array( $size ) ? implode( 'x', $size ) : $size;
     381    $class      = 'align' . esc_attr( $align ) . ' size-' . esc_attr( $size_class ) . ' wp-image-' . $id;
    381382
    382383    /**
     
    23352336    }
    23362337
    2337     $size_class  = sanitize_html_class( $atts['size'] );
     2338    $size_class  = sanitize_html_class( is_array( $atts['size'] ) ? implode( 'x', $atts['size'] ) : $atts['size'] );
    23382339    $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
    23392340
Note: See TracChangeset for help on using the changeset viewer.