javascript - Embed image into tinymce with base64 encoding - Stack Overflow

I want to embed an image into the tinymce editor but not the file, I want to embed it with this form (p

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.

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.

Share Improve this question asked Jul 21, 2017 at 7:54 benchpresserbenchpresser 2,1882 gold badges26 silver badges42 bronze badges 2
  • 1 It you use TinyMCE APIs to get content back out of the editor it should be the original Base64 version ... is that not what you get when you submit the form that contains the TinyMCE content? – Michael Fromin Commented Jul 21, 2017 at 18:56
  • Thanks, we found the problem, when we get the content we used getConent ({raw}) variation which caused base64 data to be convertd to blobs. If we called getContent(), we get the base64 data. – benchpresser Commented Jul 24, 2017 at 15:08
Add a ment  | 

1 Answer 1

Reset to default 5

try to setup this confifguration

tinymce.init({
  paste_data_images: true
});

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744191480a4562454.html

相关推荐

  • javascript - Embed image into tinymce with base64 encoding - Stack Overflow

    I want to embed an image into the tinymce editor but not the file, I want to embed it with this form (p

    9天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信