Home  >  Article  >  Backend Development  >  How to set the style after uploading pictures in Baidu ueditor, ueditor uploads pictures_PHP tutorial

How to set the style after uploading pictures in Baidu ueditor, ueditor uploads pictures_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:12:561081browse

How to set the style after uploading pictures in Baidu ueditor, ueditor uploads pictures

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/918063.htmlTechArticleHow to set the style after uploading pictures in Baidu ueditor? Ueditor encountered a problem in a recent project after uploading pictures. , the image style will be modified during content display. But the expression...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn