关于富文本kindeditor中上传本地图片成功后获取到的图片路径是相对路径修改为绝对路径

2020-01-09

找到kindeditor插件kindeditor-all.js有的或者是kindeditor.js,找到urltype的设置,将urlType 改为absolute

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 : '', //改为 urlType : 'absolute'
    newlineTag : 'p',


然后全局搜索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);
      } //这个if判断会把上传的文件路径前面的域名端口都去掉了,所以我们尝试将他们注释或者删除。就会拿到绝对路径。
  }
  return url;


文章来源于:https://blog.csdn.net/qq_37705048/article/details/80936820

{/if}