Search code examples
javascriptjquerytinymce

TinyMCE v4 turn off blobs


I don't wanna tinymce to use blobs for tiny images, because I'm converting those data:images to real images and I´m replacing the img src="" after I have real images. How could I manage it to only get data:image images? Is it possible? I tried

automatic_uploads: false

but it won't change anything.

Here is my code:

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

Solution

  • 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');
      }
    });