Remove the domain name when the umeditor editor uploads the image successfully and inserts it into the editor

When using Baidu editor umeditorv1.2.2 to upload pictures and insert them into the editor, the domain name will be as follows:

<img src="http://www.xxx.xxx/uploads/20161006/14757579522304.jpg" _src="http://www.xxx.com/uploads/20161006/14757579522304.jpg"/>

According to common sense, there should be related configuration to remove this domain name, but I didn't find it, the following is my solution

Find line 36 of the js file ueditor\dialogs\image\image.js

Change it to the following, replace the domain name in the image path

$.each($imgs, function(index, node) {
    $(node).removeAttr("width").removeAttr("height");
    // if (node.width > editor.options.initialFrameWidth) {
    // me.scale(node, editor.options.initialFrameWidth -
    // parseInt($(editor.body).css("padding-left")) -
    // parseInt($(editor.body).css("padding-right ")));
    // }
    //The following line is the newly added code, and a new imgsrc variable is added. Note that the path of node.src is used directly.
    var imgsrc = node.src.replace(window.location.protocol + '//' + window.location.hostname, '');
    return arr.push({
        _src: imgsrc,
        src: imgsrc
    });

});

The effect after modification


Then configure next :


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325787264&siteId=291194637