Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include base64 image in tinymce

Tags:

tinymce

I'm having a problem including a base64 image using tinymce.activeEditor.execCommand('mceInsertContent',

The following works:

tinymce.activeEditor.execCommand("mceInsertContent", true, "<img style = 'height:80px;width:80px' src='/Content/image.png' />");`

tinymce.activeEditor.execCommand("mceInsertContent", true, "<div>safasfdasfd</div>");

But when using tinymce.activeEditor.execCommand('mceInsertContent', true, img64);
where img64 is a base64 image received from a MVC partial view converted to string.

Does someone have a working example. I don't know if the syntax is wrong or if there is some option I have forgotten?

Update:

The following do not work:

tinymce.activeEditor.execCommand("mceInsertContent", true, "<img style='height:80px;width:80px' src='data:image/png;base64,/some long 64 string is here'>");

Does anyone know why this is not working? Some help would be greatly appreciated.

like image 930
asdfasdf Avatar asked Jul 31 '26 09:07

asdfasdf


1 Answers

It seems that others are having this problem as well. Until there is an official way to solve your problem, there is a workaround posted in this thread: https://github.com/buddyexpress/bdesk_photo/issues/2

UPDATE: Solution is to add paste_data_images : true to your configuration. See the docs here: http://www.tinymce.com/wiki.php/Configuration:paste_data_images

like image 96
Nathan Avatar answered Aug 03 '26 01:08

Nathan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!