Max-width captions reverted in 4.9.5

In WordPress 4.9.0 the caption shortcode output was changed to use an inline max-width style instead of width. This change broke several existing themes and has been reverted in trunk 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 );