Max-width captions reverted in 4.9.5

In WordPress 4.9.0 the caption shortcodeShortcode A shortcode is a placeholder used within a WordPress post, page, or widget to insert a form or function generated by a plugin in a specific location on your site. output was changed to use an inline max-width style instead of width. This change broke several existing themes and has been reverted in trunktrunk A directory in Subversion containing the latest development code in preparation for the next major release cycle. If you are running "trunk", then you are on the latest revision. and will be in 4.9.5, when released.

For background, the change was added via #33981 and was reverted in #43123.

Any themes that would like to maintain the behavior from 4.9.0 can do so by filtering the output of image captions like this:

function filter_caption_max_width( $output, $tag ) {
    if ( 'caption' === $tag || 'wp_caption' === $tag ) {
        $output = str_replace( 'width:', 'max-width:', $output );
    }

    return $output;
}

add_filter( 'do_shortcode_tag', 'filter_caption_max_width', 10, 2 );

#4-9-5