Make WordPress Core

Ticket #49601: 49601-2.diff

File 49601-2.diff, 1.2 KB (added by joelhardi, 5 years ago)

new patch that removes hardcoded width on container <figure> and puts max-width on caption element, see my comment

  • src/wp-includes/media.php

     
    17861786        $style = '';
    17871787
    17881788        if ( $caption_width ) {
    1789                 $style = 'style="width: ' . (int) $caption_width . 'px" ';
     1789                $style = 'style="max-width: ' . (int) $caption_width . 'px" ';
    17901790        }
    17911791
    17921792        if ( $html5 ) {
    17931793                $html = sprintf(
    1794                         '<figure %s%s%sclass="%s">%s%s</figure>',
     1794                        '<figure %s%sclass="%s">%s%s</figure>',
    17951795                        $id,
    17961796                        $describedby,
    1797                         $style,
    17981797                        esc_attr( $class ),
    17991798                        do_shortcode( $content ),
    18001799                        sprintf(
    1801                                 '<figcaption %sclass="wp-caption-text">%s</figcaption>',
     1800                                '<figcaption %s%sclass="wp-caption-text">%s</figcaption>',
    18021801                                $caption_id,
     1802                                $style,
    18031803                                $atts['caption']
    18041804                        )
    18051805                );
    18061806        } else {
    18071807                $html = sprintf(
    1808                         '<div %s%sclass="%s">%s%s</div>',
     1808                        '<div %sclass="%s">%s%s</div>',
    18091809                        $id,
    1810                         $style,
    18111810                        esc_attr( $class ),
    18121811                        str_replace( '<img ', '<img ' . $describedby, do_shortcode( $content ) ),
    18131812                        sprintf(
    1814                                 '<p %sclass="wp-caption-text">%s</p>',
     1813                                '<p %s%sclass="wp-caption-text">%s</p>',
    18151814                                $caption_id,
     1815                                $style,
    18161816                                $atts['caption']
    18171817                        )
    18181818                );