文檔說明
convert_urls
該選項允許你控制TinyMCE是否夠聰明,存儲URL的原始值,默認情況URL會被自動轉化,因爲內置的瀏覽器邏輯以這樣的方式工作,沒有方法獲 取真正的URL,除非你別處存儲。如果你設置該選項爲false,那麼它會試着保持URL的完整性。默認爲true,意味着URL會依據 relative_urls的狀態而被強制爲絕對或相對的。
Convert_urls選項示例:
tinyMCE.init({
...
convert_urls : false
});
relative_urls
如果該選項設爲true,所有通過MCFileManager返回的URL都會與知道的document_base_url相關。如果設爲false,所有URL會被轉化成絕對URL,默認爲true。
relative_urls選項示例:
tinyMCE.init({
...
relative_urls : false
});
remove_script_host
該選項允許MCFileManager返回的URL的協議和主機部分被刪除,該選項僅在relative_urls選項設爲false時有用
,該選項默認爲true。
URL會以格式“/somedir/somefile.htm”返回而不是默認的http://www.somesite.com/somedir/somefile.htm的格式。
remove_script_host選項示例:
tinyMCE.init({
...
remove_script_host : false
});
document_base_url
該選項爲文檔中所有相對的URL指定URL基礎,默認值爲當前文檔的目錄。如果提供了值,一定要是目錄(而不是文檔),必須以“/”結尾。該選項還 與relative_urls,remove_script_host和convert_urls選項結合使用以確定TinyMCE返回相對還是絕對的 URL。常見問題包含了詳細描述和使用相對/絕對URL工作的示例頁面。
3.0版本的修改:這可能會影響其他路徑如何解析,如調用tinyMCE.windowManager.open方法,因此你可能想要使用絕對路徑,下面的配置似乎也受到document_base_url設置的影響:
external_link_list_url
external_image_list_url
document_base_url選項示例:
tinyMCE.init({
...
document_base_url : "http://www.site.com/path1/";
});
上面的文檔摘自:https://www.cnblogs.com/zhaiqianfeng/archive/2012/07/18/4616859.html
中文api文檔參考:
鏈接: 配置參考 \ 圖片&文件上傳配置
鏈接: 簡介與入門 \ 上傳圖片和文件
實操
目錄說明
最終上傳的文件都在
配置一
relative_urls: false, //使用相對url?
remove_script_host: true, //是否刪除url域名部分
document_base_url: "http://localhost:8080/guoYouZiChanglc/files/",
頁面預覽的效果
<img src="/guoYouZiChanglc/files\articleFile\2020-06-17\20200617162145160.jpg" alt="撒大聲地" width="111" height="74">
配置二
relative_urls: false, //使用相對url?
remove_script_host: true, //是否刪除url域名部分
document_base_url: "/",
頁面預覽的效果
<img src="/guoYouZiChanglc/files\articleFile\2020-06-17\20200617165347547.jpg" alt="1" width="111" height="74">
配置三
relative_urls: false, //使用相對url?
remove_script_host: true, //是否刪除url域名部分
頁面預覽的效果
<img src="/guoYouZiChanglc/files\articleFile\2020-06-17\20200617165521123.jpg" alt="1" width="111" height="54">
配置四
relative_urls: false, //使用相對url?
remove_script_host: false, //是否刪除url域名部分
document_base_url: "/",
頁面預覽的效果
<img src="http://localhost:8080/guoYouZiChanglc/files\articleFile\2020-06-17\20200617170159687.jpg" alt="1" width="111" height="74">
配置五
relative_urls: false, //使用相對url?
remove_script_host: false, //是否刪除url域名部分
document_base_url: "/guoYouZiChanglc/",
頁面預覽的效果
<img src="http://localhost:8080/guoYouZiChanglc/files\articleFile\2020-06-17\20200617170647992.jpg" alt="1" width="111" height="74">
配置五
relative_urls: false, //使用相對url?
remove_script_host: false, //是否刪除url域名部分
document_base_url: "http://localhost:8080/guoYouZiChanglc/",//我當前的項目預覽就是這個
頁面預覽的效果
<img src="http://localhost:8080/guoYouZiChanglc/files\articleFile\2020-06-17\20200617173305633.jpg" alt="1" width="111" height="74">
配置五
relative_urls: false, //使用相對url?
remove_script_host: false, //是否刪除url域名部分
document_base_url: "http://110.110.121.8/guoYouZiChanglc/",,//這是項目的上線地址,我瞎寫的
由於我當前實際是在本地進行的調試的,也就是localhost,如果把這個地址改爲這個,圖片都不能上傳了
配置五
relative_urls: false, //使用相對url?
remove_script_host: false, //是否刪除url域名部分
document_base_url: "http://localhost:8080/",
頁面預覽的效果
<img src="http://localhost:8080/guoYouZiChanglc/files\articleFile\2020-06-17\20200617173908740.jpg" alt="1" width="111" height="54">
配置6
relative_urls: true, //使用相對url?
document_base_url: "/guoYouZiChanglc/",
頁面預覽的效果
<img src="files\articleFile\2020-06-17\20200617171003981.jpg" alt="1" width="111" height="74">
配置7
relative_urls: true, //使用相對url?
document_base_url: "http://localhost:8080/guoYouZiChanglc/",
頁面預覽的效果
<img src="files\articleFile\2020-06-17\20200617171241124.jpg" alt="1111" width="111" height="74">
配置8
relative_urls: true, //使用相對url?
document_base_url: "/",
頁面預覽的效果
<img src="guoYouZiChanglc/files\articleFile\2020-06-17\20200617171758172.jpg" alt="1" width="111" height="74">