diff --git a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js index 5f34daa..a560523 100644 --- a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js @@ -299,6 +299,8 @@ var uploadButtonId = '#' + form.find('[data-drupal-selector=edit-fid-upload-button]').attr('id'); var ajaxObject = getAjaxObject(uploadButtonId); + // Add the dropped image file to the form. + // @see Drupal.Ajax.prototype.beforeSerialize ajaxObject.beforeSerialize = function (element_settings, options) { formData.append('files[fid]', file); $.each(this.$form.serializeArray(), function (k, v) { @@ -306,7 +308,16 @@ formData.append(v.name, v.value); }); options.data = formData; + // jQuery.ajax() by default sets the contentType as + // "application/x-www-form-urlencoded; charset=UTF-8". As of + // jQuery 1.6 you can pass false to tell jQuery to not set any + // content type header. + // @see http://api.jquery.com/jquery.ajax/ options.contentType = false; + // By default, data passed in to the data option as an object. In + // order to send a DOMDocument, or other non-processed data, we + // need to set this option to false. + // @see http://api.jquery.com/jquery.ajax/ options.processData = false; }; @@ -317,6 +328,8 @@ var preview = editor.document.findOne('[data-cke-drupalimage-preview]'); if (preview) { preview.remove(); + // Prevent reverting back to the preview image when using undo. + editor.fire('updateSnapshot'); } }); } @@ -423,14 +436,15 @@ * * @param {string} id * The selector id. - * @returns {Object} + * @return {Object} * The Drupal AJAX instance, or null. */ function getAjaxObject(id) { var ajaxInstance = null; $.each(Drupal.ajax.instances, function (k, v) { if (v !== null && v.selector === id) { - return ajaxInstance = Drupal.ajax.instances[k]; + ajaxInstance = Drupal.ajax.instances[k]; + return ajaxInstance; } }); return ajaxInstance;