【问题标题】:TinyMCE v4 turn off blobsTinyMCE v4 关闭 blob
【发布时间】:2017-03-24 11:59:07
【问题描述】:

我不想 tinymce 将 blob 用于小图像,因为我正在将这些 data:images 转换为真实图像,并且在获得真实图像后我将替换 img src=""。我怎么能管理它只得到data:image 图像?是否可以? 我试过了

automatic_uploads: false

但它不会改变任何东西。

这是我的代码:

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();
        });
    }
});

【问题讨论】:

    标签: javascript jquery tinymce


    【解决方案1】:

    可以通过添加以下过滤器来禁用 Blob 转换:

    TinyMCE docs: images_dataimg_filter

    tinymce.init({
       images_dataimg_filter: function(img) {
          return img.hasAttribute('internal-blob');
      }
    });
    

    【讨论】:

    • 这很好用。使用 blob,我无法将数据从 tinymce 主体正确保存到 DB,因为其中有 blob。这样,图像将被存储为 base64 并正确保存到 DB。
    • 谢谢你,正是我想要的!
    • 为了这个简单的修复程序花了大约一个小时。谢谢!
    • 这在 5.3 中已被弃用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-23
    • 1970-01-01
    相关资源
    最近更新 更多