I have ran into a problem using TinyMCE in Handling Async Image Upload using Servlet as backend.
There are two major problems:
Even after using
pasteplugin and settingpaste_data_images:true, images are not getting automatically pasted while pasting together with text from MS Word, only text got paste and images getting missed, whereas, when I paste an image alone it is getting pasted.After pasting images, TinyMCE supposed to upload them asynchronously and update
<img>'ssrcattribute to thelocationproperty returned by thejsonfrom backend.
Now the problem arise here that when I paste the image alone it gets automatically uploaded in backend and proper response is coming back with image's location as a JSON, I have verified that with browser console and also via manual Image Insert option. But after all this the <img scr> is being blank and the image turned into black boundary.
Please help me if anyone have faced similar issue whereas back end can be anything, as I don't think it is a problem with back end.
The Code:
TinyMCE:
<script type="text/javascript" charset="utf-8">
tinymce.init({
selector: '#description',
plugins: "image link imagetools codesample emoticons autoresize textcolor table preview wordcount paste",
menubar: 'edit | format | insert | table',
toolbar1: 'undo redo | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
toolbar2: 'forecolor backcolor | codesample emoticons',
automatic_uploads: true,
images_upload_url: 'uploadFile',
images_upload_credentials: true,
images_upload_base_path: '',
paste_data_images: true,
file_browser_callback_types: 'image',
convert_urls: false,
file_browser_callback: function(field_name, url, type, win) {
tinymce.activeEditor.windowManager.open({
title: "File Browser",
type: "image",
url: "uploadFile",
width: 550,
height: 200
}, {
oninsert: function(url) {
win.document.getElementById(field_name).value = url;
}
});
}
});
</script>
Back end Response after image upload:
[{ "location": "./uploaded/images/201617175645_blobid0.png" }]
<img> tag after image upload:
<img src="" alt="" data-mce-src="" data-mce-selected="1">
Chrome console show no exception or warning at all while pasting image or after uplooding it. Please let me know if anyone have any solution for the problem or some way to get the actual reason behind it. Let me know if anything need more explanation above.