TinyMCE添加图片 路径自动处理成相对路径

默认状况下会自动转换你的图片路径如:浏览器

转换:less

/path/name.jpgui

this

../path/name.jpgurl

带有域名的路径也会被转换为相对路径。spa

 

须要修改一个设置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.rest

翻译:code

这个选项使您可以控制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

相关文章
相关标签/搜索