默认情况下会自动转换你的图片路径如:
转换:
/path/name.jpg
为
../path/name.jpg
带有域名的路径也会被转换为相对路径。
需要修改一个设置convert_urls,官方文档:
https://www.tinymce.com/docs/configure/url-handling/#convert_urls
This option enables you to control whether TinyMCE is to be clever and restore URLs to their original values. URLs are automatically converted (messed up) by default because the browser's built-in logic works this way. There is no way to get the real URL unless you store it away. If you set this option to false it will try to keep these URLs intact. This option is set to true by default, which means URLs will be forced to be either absolute or relative depending on the state of relative_urls.
翻译:
这个选项使您能够控制TinyMCE是否聪明的url和恢复到原来的值。默认url自动转换(混乱),因为浏览器内置的逻辑处理。没有办法真正的URL,除非你存起来了。如果您设置这个选项错误会尽量保持这些url完好无损。这个选项是默认设置为true,这意味着url将被迫是绝对或相对取决于relative_urls的状态。
因此在初始化时候,多添加一个参数:
tinymce.init({ selector: 'textarea', // change this value according to your HTML convert_urls: false //这个参数加上去就可以了 });
TinyMCE的中文教程不多,想搜索一些解决办法,都很难找到。就算有也是针对于老版本的。PS.自己整合了一下前人弄的上传图片的插件,总算搞定了。by OSFIPIN