]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/media/editor_plugin_src.js
WordPress 3.5.1
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / media / editor_plugin_src.js
index a0d4ef2ae38b8a0be50b61bcaae842874e414dbc..2ca33ac0ed28ba340db084097c1f0bba173f64c5 100644 (file)
                ["Audio"]
        ];
 
+       function normalizeSize(size) {
+               return typeof(size) == "string" ? size.replace(/[^0-9%]/g, '') : size;
+       }
+
        function toArray(obj) {
                var undef, out, i;
 
                                'data-mce-json' : JSON.serialize(data, "'")
                        });
 
-                       img.width = data.width || (data.type == 'audio' ? "300" : "320");
-                       img.height = data.height || (data.type == 'audio' ? "32" : "240");
+                       img.width = data.width = normalizeSize(data.width || (data.type == 'audio' ? "300" : "320"));
+                       img.height = data.height = normalizeSize(data.height || (data.type == 'audio' ? "32" : "240"));
 
                        return img;
                },
                        data = JSON.parse(data);
                        typeItem = this.getType(node.attr('class'));
 
-                       style = node.attr('data-mce-style')
+                       style = node.attr('data-mce-style');
                        if (!style) {
                                style = node.attr('style');
 
                                        style = editor.dom.serializeStyle(editor.dom.parseStyle(style, 'img'));
                        }
 
+                       // Use node width/height to override the data width/height when the placeholder is resized
+                       data.width = node.attr('width') || data.width;
+                       data.height = node.attr('height') || data.height;
+
                        // Handle iframe
                        if (typeItem.name === 'Iframe') {
                                replacement = new Node('iframe', 1);
                                // Create new object element
                                video = new Node('video', 1).attr(tinymce.extend({
                                        id : node.attr('id'),
-                                       width: node.attr('width'),
-                                       height: node.attr('height'),
+                                       width: normalizeSize(node.attr('width')),
+                                       height: normalizeSize(node.attr('height')),
                                        style : style
                                }, data.video.attrs));
 
                                // Create new object element
                                audio = new Node('audio', 1).attr(tinymce.extend({
                                        id : node.attr('id'),
-                                       width: node.attr('width'),
-                                       height: node.attr('height'),
+                                       width: normalizeSize(node.attr('width')),
+                                       height: normalizeSize(node.attr('height')),
                                        style : style
                                }, data.video.attrs));
 
                                embed.shortEnded = true;
                                embed.attr({
                                        id: node.attr('id'),
-                                       width: node.attr('width'),
-                                       height: node.attr('height'),
+                                       width: normalizeSize(node.attr('width')),
+                                       height: normalizeSize(node.attr('height')),
                                        style : style,
                                        type: node.attr('type')
                                });
                                // Create new object element
                                object = new Node('object', 1).attr({
                                        id : node.attr('id'),
-                                       width: node.attr('width'),
-                                       height: node.attr('height'),
+                                       width: normalizeSize(node.attr('width')),
+                                       height: normalizeSize(node.attr('height')),
                                        style : style
                                });
 
                                        embed.shortEnded = true;
                                        embed.attr({
                                                id: node.attr('id'),
-                                               width: node.attr('width'),
-                                               height: node.attr('height'),
+                                               width: normalizeSize(node.attr('width')),
+                                               height: normalizeSize(node.attr('height')),
                                                style : style,
                                                type: typeItem.mimes[0]
                                        });
 
                        if (iframe) {
                                // Get width/height
-                               width = iframe.attr('width');
-                               height = iframe.attr('height');
+                               width = normalizeSize(iframe.attr('width'));
+                               height = normalizeSize(iframe.attr('height'));
                                style = style || iframe.attr('style');
                                id = iframe.attr('id');
                                hspace = iframe.attr('hspace');