關於富文本kindeditor中上傳本地圖片成功后獲取到的圖片路徑是相對路徑修改為絕對路徑


找到kindeditor插件kindeditor-all.js,找到urltype的設置,

K.options = {
    designMode : true,
    fullscreenMode : false,
    filterMode : true,
    wellFormatMode : true,
    shadowMode : true,
    loadStyleMode : true,
    basePath : K.basePath,
    themesPath : K.basePath + 'themes/',
    langPath : K.basePath + 'lang/',
    pluginsPath : K.basePath + 'plugins/',
    themeType : 'default',
    langType : 'zh-CN',
    urlType : 'absolute',
    newlineTag : 'p',

改為absolute。然后全局搜索absolute,找到下面一行代碼:

if (mode === 'relative') {
        url = getRelativePath(host + pathname, 0).substr(2);
    } else if (mode === 'absolute') {
        // if (url.substr(0, host.length) === host) {
        //  url = url.substr(host.length);
        // }
    }
    return url;
if (url.substr(0, host.length) === host) {
      url = url.substr(host.length);
 }這行代碼會把上傳的文件路徑前面的域名端口都剪掉了,所以我們嘗試將他們注釋或者刪除。就會拿到絕對路徑。

 

作者:weijun-w
來源:CSDN
原文:https://blog.csdn.net/qq_37705048/article/details/80936820


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM