Insert image in tinymce with base64 encoding

I want to insert an image into tinymce editor, but not a file, I want to embed it in this form (put your base64 data directly)

<img src="data:image/png;base64,ABCD..."></img>

      

I store image data in a variable,

var data= '<img src="data:image/png;base64,ABCD..."></img>';

      

When I call

tinyMCE.execCommand('mceInsertContent', false, data);

      

or

tinyMCE.execCommand('mceInsertRawHTML', false, data);

      

or

tinyMCE.activeEditor.setContent(data, {format:'raw'});

      

after the call, when I get the HTML back, we have:

<img src="blob:XYZ">

but the blob content is not the same as the data we provide, it is very short and we cannot see the image if we reuse this HTML in another browser. TinyMCE uses this BLOB: .. for caching, but I don't want caching.

+3


source to share


1 answer


try to install this config

tinymce.init({
  paste_data_images: true
});

      



https://www.tinymce.com/docs/plugins/paste/#paste_data_images

0


source







All Articles