Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TinyMCE 4 strips img tags with base64 #2

Closed
Fmstrat opened this issue Dec 23, 2014 · 12 comments
Closed

TinyMCE 4 strips img tags with base64 #2

Fmstrat opened this issue Dec 23, 2014 · 12 comments

Comments

@Fmstrat
Copy link

Fmstrat commented Dec 23, 2014

I'm still trying to figure out how to fix this myself, but the instructions should be updated once this is resolved.

@lianglee
Copy link
Contributor

Actually this plugin automatically convert img to base64

@cafealternativo
Copy link

tinymce was stripping the base64 node, so nothing was being inserted. . If you are experiencing this problem make the following modifications.

1- The insertContent command parses the node and deletes the content. Even mceInsertRawHTML doesn't work because it has the raw parameter turned off, so we need a new command.
After the addButton sentence add the following command to tinymce.

//---------------------------
editor.addCommand("trueInsertRawHTML", function (value) {
this.selection.setContent('tiny_mce_marker');
editor.setContent(
editor.getContent().replace(/tiny_mce_marker/g, function () {
return value;
}), { format: "raw" }
);
});
//-------------------

2- Replace this line:

editor.execCommand("mceInsertContent", false, "");

With:

editor.execCommand("trueInsertRawHTML", "");

Hope this helps the next customer...

@lianglee
Copy link
Contributor

lianglee commented Apr 7, 2015

Fixed thanks

@lianglee lianglee closed this as completed Apr 7, 2015
@nathancarter
Copy link

I created a TinyMCE bug report for this. Vote for it here:
http://www.tinymce.com/develop/bugtracker_view.php?id=7549

@nathancarter
Copy link

Actually, the solution for this is a tiny tweak to your TinyMCE configuration. See here:
http://stackoverflow.com/a/30767277/670492

@xaviergonz
Copy link
Contributor

and you can use this in your tinymce 4 init script so your images are really saved as base64 (even pasted ones)

    paste_data_images: true,
    images_upload_handler: function (blobInfo, success, failure) {
      // no upload, just return the blobInfo.blob() as base64 data
      success("data:" + blobInfo.blob().type + ";base64," + blobInfo.base64());
    }

PS: with this code you don't need to change mceInsertContent, it will work

@lianglee
Copy link
Contributor

@xaviergonz , can you send pull request? or send us complete file with changes, we shall update it.

Thanks

@xaviergonz
Copy link
Contributor

How would I? The code needs to be added to the tinymce.init() function, not to your plugin itself.

@lianglee
Copy link
Contributor

@xaviergonz ok thanks 👍

@xaviergonz
Copy link
Contributor

I did create a pull request based on the code I use, but it is quite a big pull request :)
It does work in tinymce 4 latest version (tested), however I did not test it with v3.

@zkozma
Copy link

zkozma commented Feb 12, 2018

Thx xaviergonz! The images_upload_handler is working!

@syedzahed
Copy link

@xaviergonz Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants