Ticket #33477: 33477.patch
| File 33477.patch, 1.8 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
157 157 } 158 158 159 159 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 ) { 161 161 var out = ''; 162 162 163 if ( b.indexOf('<img ') === -1 ) {163 if ( dl.indexOf('<img ') === -1 ) { 164 164 // Broken caption. The user managed to drag the image out? 165 165 // 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 ); 167 167 168 168 if ( out && out[1] ) { 169 169 return '<p>' + out[1] + '</p>'; … … 172 172 return ''; 173 173 } 174 174 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 ) { 176 176 var id, classes, align, width; 177 177 178 178 width = c.match( /width="([0-9]*)"/ ); … … 212 212 if ( out.indexOf('[caption') === -1 ) { 213 213 // the caption html seems broken, try to find the image that may be wrapped in a link 214 214 // 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' ); 216 216 } 217 217 218 218 return out;