Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed image into tinymce with base64 encoding

I want to embed an image into the tinymce editor but not the file, I want to embed it with this form (put its base64 data directly)

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

I store the image data in a variable,

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

When I invoke

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

or

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

or

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

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

<img src="blob:XYZ">

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

like image 505
benchpresser Avatar asked Jul 21 '17 07:07

benchpresser


1 Answers

try to setup this confifguration

tinymce.init({
  paste_data_images: true
});

https://www.tiny.cloud/docs/plugins/paste/#paste_data_images

like image 146
Netorica Avatar answered Oct 22 '22 20:10

Netorica