在TinyMCE中设置数据URI [英] Set data URI in TinyMCE
问题描述
TinyMCE init选项
TinyMCE init options
$scope.tinymceOptions = {
plugins: 'base64img image imagetools paste ...',
relative_urls: false,
paste_data_images: true,
...
};
paste_data_images:true
option表示<$不应从粘贴的内容中删除c $ c> data:url 图像(内嵌图像)(参见 docs 。
我使用TinyMCE 4.2.8。在 base64img
插件里面我写了以下代码
paste_data_images: true
option means that data:url
images (inline images) should NOT be removed from the pasted contents (see docs).
I use TinyMCE 4.2.8. Inside base64img
plugin I've written the following code
var editor; // TinyMCE editor
var imgData; // base64 image data string, like "data:image/png;base64,...="
editor.setContent("<img src='" + imgData + "' />", {format: 'raw'});
// editor.execCommand('mceInsertRawHtml', false, '<img src=\'' + imgData + '\' />'); // another way
到嵌入图像,它作为base64字符串加载到内存中。执行命令后,img src 神奇地转换为'blob:http%3A // localhost%3A8080 /...'
。 为什么?
to embed an image which is loaded in memory as base64 string. After the command is executed img src is magically converted into 'blob:http%3A//localhost%3A8080/...'
. Why?
它有效(显示图像),但我想将图像存储为数据:
而不是将它们上传到服务器并存储为 blob
。 如何更改此行为?
It works (images are displayed), but I want to store images as data:
rather than upload them to server and store as blob
. How to change this behaviour?
推荐答案
图片内部保存为' data:image / png; base64,... ='
,所以你不必担心。没有上传,'blob:http%3A // localhost%3A8080 /...'
仅用于显示图片信息。
Image is saved internally as 'data:image/png;base64,...='
, so you don't need to worry. No uploading is performed, 'blob:http%3A//localhost%3A8080/...'
is used for displaying an image info only.
这篇关于在TinyMCE中设置数据URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!