Ueditor custom editing, such as the need to do lazy loading, this time need to customize the picture, but, Ueditor will remove the img above the attributes, such as data-original and the remote image upload automatically.
At this time, first, you need to give the image automatic upload plus attributes, as for the Jquery.lazyload delay loading of the picture, must have the data-original attribute, as long as the detection of this property, it is not remotely uploaded. Additional properties Customize the mention of the house, the code is as follows:
' Wordimage ': {
execCommand:function () { var images = domUtils.getElementsByTagName(me.body, "img"); var urlList = []; for (var i = 0, ci; ci = images[i++];) { if(ci.getAttribute("data-original")||ci.getAttribute("original")||ci.getAttribute("local")||ci.getAttribute("remote")||ci.getAttribute("qiniu")){ break; }else { var url = ci.getAttribute("word_img"); url && urlList.push(url); } } return urlList; },
Second, remove, for script filter, for script tag, add specific ID alive class, do not let ueditor processing.
case ‘style‘: case ‘script‘: if(node.id===‘andyZhou‘||node.className==="andyZhou"){ break; }else { node.setAttr({ cdata_tag: node.tagName, cdata_data: (node.innerHTML() || ‘‘), ‘_ue_custom_node_‘:‘true‘ }); node.tagName = ‘div‘; node.innerHTML(‘‘); break; } break;
Third, add the script and style tags to the whitelist.
script:[‘src‘,‘defer‘,‘async‘,‘charset‘], source:[‘src‘], style:[],
At this point, you can customize your edits in HTML mode and enjoy the benefits of Ueditor.
This is DIY casually pondering, if there is a better mode, please advise, more.
Reprint Please specify source: Ueditor style filter removal and remote image upload customization-phpcms tutorial-Zhou Lujun's personal website please add link description
Ueditor style filter removal and remote image upload customization