I encountered a problem in a recent project. After Ueditor uploads pictures, the picture style will be modified during content display. But emoticons are also img tags, so global modification is problematic,
So I can only start modifying the plug-in code.
First find the server segment file where the image is uploaded. This is mainly about PHP
Find line 337 of Uploader.class.php in the php directory
public function getFileInfo() { return array( "state" => $this->stateInfo, "url" => $this->fullName, "title" => $this->fileName, "original" => $this->oriName, "type" => $this->fileType, "class"=> "aaa" "size" => $this->fileSize, ); }
The json returned in this way has one more class attribute value
One is to modify js
Find the following code 24461 in ueditor.all.js
Modify js
function callback(){ try{ var link, json, loader, body = (iframe.contentDocument || iframe.contentWindow.document).body, result = body.innerText || body.textContent || ''; json = (new Function("return " + result))(); link = me.options.imageUrlPrefix + json.url; if(json.state == 'SUCCESS' && json.url) { loader = me.document.getElementById(loadingId); loader.setAttribute('src', link); loader.setAttribute('_src', link); loader.setAttribute('class', json.class || ''); //添加行代码 loader.setAttribute('title', json.title || ''); loader.setAttribute('alt', json.original || ''); loader.removeAttribute('id'); domUtils.removeClasses(loader, 'loadingclass'); } else { showErrorLoader && showErrorLoader(json.state); } }catch(er){ showErrorLoader && showErrorLoader(me.getLang('simpleupload.loadError')); } form.reset(); domUtils.un(iframe, 'load', callback); }
When you upload a picture in this way, you can see that the uploaded pictures have additional styles.