WordPress.org

Make WordPress Core

Ticket #24225: 24225.4.diff

File 24225.4.diff, 776 bytes (added by kovshenin, 5 years ago)
  • wp-admin/includes/media.php

     
    150150        // convert any remaining line breaks to <br>
    151151        $caption = preg_replace( '/[ \n\t]*\n[ \t]*/', '<br />', $caption );
    152152
    153         $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html );
    154         if ( empty($align) )
     153        // Remove alignment classes
     154        $html = preg_replace( '/(class=(["\'])(?:(?!\2).)*?)align(?:none|left|right|center)\s?/', '$1', $html );
     155        if ( empty( $align ) )
    155156                $align = 'none';
    156157
    157158        $shcode = '[caption id="' . $id . '" align="align' . $align     . '" width="' . $width . '"]' . $html . ' ' . $caption . '[/caption]';