TinyMCE v4关闭Blob

ElD*_*olo 5 javascript jquery tinymce

我不想tinymce对微小的图像使用blob,因为我会将它们转换data:images为真实图像,而img src=""在拥有真实图像之后将替换。我如何管理它仅获取data:image图像?可能吗?我试过了

automatic_uploads: false
Run Code Online (Sandbox Code Playgroud)

但它不会改变任何东西。

这是我的代码:

tinymce.init({
    selector: strSelector + "textarea:not(#strDescription)",
    paste_data_images: true,
    image_advtab: true,
    mode: "specific_textareas",
    editor_selector: "mceEditor",
    automatic_uploads: false,
    file_picker_callback: function(callback, value, meta) {
        if (meta.filetype == 'image') {
            $('#upload').trigger('click');
            $('#upload').on('change', function() {
                var file = this.files[0];
                var reader = new FileReader();
                reader.onload = function(e) {
                    callback(e.target.result, {
                        alt: ''
                    });
                };
                reader.readAsDataURL(file);
            });
        }
    },
    plugins: [
        "advlist autolink lists link image imagetools charmap preview anchor code",
        "searchreplace visualblocks code fullscreen",
        "insertdatetime table contextmenu paste imagetools"
    ],
    setup: function(editor) {
        editor.on('change', function() {
            editor.save();
        });
    }
});
Run Code Online (Sandbox Code Playgroud)

Siv*_*lan 7

Blob conversion can be disabled by adding the filter below:

TinyMCE docs: images_dataimg_filter

tinymce.init({
   images_dataimg_filter: function(img) {
      return img.hasAttribute('internal-blob');
  }
});
Run Code Online (Sandbox Code Playgroud)

  • 这在 5.3 中已被弃用 (4认同)
  • 这很好用。使用 blob 我无法将数据从 tinymce body 正确保存到 DB,因为其中有 *blob*。有了这个,图像存储为 base64 并正确保存到数据库中。 (2认同)