关于富文本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