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

相關文章
相關標籤/搜索