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

默认情况下会自动转换你的图片路径如:

转换:

/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

转载于:https://www.cnblogs.com/osfipin/p/5763883.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值