Make WordPress Core

Ticket #33477: 33477.patch

File 33477.patch, 1.8 KB (added by azaozz, 11 years ago)
  • src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

     
    157157        }
    158158
    159159        function getShortcode( content ) {
    160                 return content.replace( /<div (?:id="attachment_|class="mceTemp)[^>]*>([\s\S]+?)<\/div>/g, function( a, b ) {
     160                return content.replace( /(?:<div [^>]+mceTemp[^>]+>)?\s*(<dl [^>]+wp-caption[^>]+>[\s\S]+?<\/dl>)\s*(?:<\/div>)?/g, function( all, dl ) {
    161161                        var out = '';
    162162
    163                         if ( b.indexOf('<img ') === -1 ) {
     163                        if ( dl.indexOf('<img ') === -1 ) {
    164164                                // Broken caption. The user managed to drag the image out?
    165165                                // Try to return the caption text as a paragraph.
    166                                 out = b.match( /<dd [^>]+>([\s\S]+?)<\/dd>/i );
     166                                out = dl.match( /<dd [^>]+>([\s\S]+?)<\/dd>/i );
    167167
    168168                                if ( out && out[1] ) {
    169169                                        return '<p>' + out[1] + '</p>';
     
    172172                                return '';
    173173                        }
    174174
    175                         out = b.replace( /\s*<dl ([^>]+)>\s*<dt [^>]+>([\s\S]+?)<\/dt>\s*<dd [^>]+>([\s\S]*?)<\/dd>\s*<\/dl>\s*/gi, function( a, b, c, caption ) {
     175                        out = dl.replace( /\s*<dl ([^>]+)>\s*<dt [^>]+>([\s\S]+?)<\/dt>\s*<dd [^>]+>([\s\S]*?)<\/dd>\s*<\/dl>\s*/gi, function( a, b, c, caption ) {
    176176                                var id, classes, align, width;
    177177
    178178                                width = c.match( /width="([0-9]*)"/ );
     
    212212                        if ( out.indexOf('[caption') === -1 ) {
    213213                                // the caption html seems broken, try to find the image that may be wrapped in a link
    214214                                // and may be followed by <p> with the caption text.
    215                                 out = b.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' );
     215                                out = dl.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' );
    216216                        }
    217217
    218218                        return out;