Index: /trunk/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js
===================================================================
--- /trunk/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js (revision 20012)
+++ /trunk/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js (revision 20013)
@@ -142,11 +142,11 @@
var id, cls, w, cap, div_cls;
- id = b.match(/id=['"]([^'"]+)['"] ?/);
+ id = b.match(/id=['"]([^'"]*)['"] ?/);
b = b.replace(id[0], '');
- cls = b.match(/align=['"]([^'"]+)['"] ?/);
+ cls = b.match(/align=['"]([^'"]*)['"] ?/);
b = b.replace(cls[0], '');
- w = b.match(/width=['"]([0-9]+)['"] ?/);
+ w = b.match(/width=['"]([0-9]*)['"] ?/);
b = b.replace(w[0], '');
@@ -160,7 +160,9 @@
return c;
- div_cls = (cls == 'aligncenter') ? 'mceTemp mceIEcenter' : 'mceTemp';
-
- return '
';
});
@@ -168,27 +170,40 @@
_get_shcode : function(content) {
- return content.replace(/\s*
]+)>\s*- ]+>([\s\S]+?)<\/dt>\s*
- ]+>([\s\S]+?)<\/dd>\s*<\/dl>\s*<\/div>/gi, function(a,b,c,cap){
- var id, cls, w;
-
- w = c.match(/width="([0-9]+)"/);
- w = ( w && w[1] ) ? w[1] : '';
-
- if ( !w || !cap )
- return c;
-
- id = b.match(/id="([^"]+)"/);
- id = ( id && id[1] ) ? id[1] : '';
-
- cls = b.match(/class="([^"]+)"/);
- cls = ( cls && cls[1] ) ? cls[1] : '';
- cls = cls.match(/align[a-z]+/) || 'alignnone';
-
- cap = cap.replace(/<[a-z][^<>]+>/g, function(a){
- return a.replace(/"/g, "'");
+ return content.replace(/
]*>([\s\S]+?)<\/div>/g, function(a, b){
+ var ret = b.replace(/
]+)>\s*- ]+>([\s\S]+?)<\/dt>\s*
- ]+>([\s\S]*?)<\/dd>\s*<\/dl>/gi, function(a,b,c,cap){
+ var id, cls, w;
+
+ w = c.match(/width="([0-9]*)"/);
+ w = ( w && w[1] ) ? w[1] : '';
+
+ if ( !w || !cap )
+ return c;
+
+ id = b.match(/id="([^"]*)"/);
+ id = ( id && id[1] ) ? id[1] : '';
+
+ cls = b.match(/class="([^"]*)"/);
+ cls = ( cls && cls[1] ) ? cls[1] : '';
+ cls = cls.match(/align[a-z]+/) || 'alignnone';
+
+ cap = cap.replace(/<[a-z][^<>]+>/g, function(a){
+ a = a.replace(/="[^"]+"/, function(b){
+ return b.replace(/'/g, ''');
+ });
+ return a.replace(/"/g, "'");
+ });
+
+ cap = cap.replace(/"/g, '"');
+
+ return '[caption id="'+id+'" align="'+cls+'" width="'+w+'" caption="'+cap+'"]'+c+'[/caption]';
});
- cap = cap.replace(/"/g, '"');
-
- return '[caption id="'+id+'" align="'+cls+'" width="'+w+'" caption="'+cap+'"]'+c+'[/caption]';
+ if ( ret.indexOf('[caption') !== 0 ) {
+ // the caption html seems brocken, try to find the image that may be wrapped in a link
+ // and may be followed by
with the caption text.
+ ret = b.replace(/[\s\S]*?((?:]+>)?]+>(?:<\/a>)?)([\s\S]*<\/p>)?[\s\S]*/gi, '
$1
$2');
+ }
+
+ return ret;
});
},