: This article describes how to set styles after Baidu ueditor uploads images. if you are interested in the PHP Tutorial, refer to it. UEditor is a rich text web editor developed by Baidu web front-end R & D department. it is lightweight, customizable, and focuses on user experience. it is open-source based on the MIT protocol and allows you to freely use and modify code, featured features of the popular rich text editor and various new editing modes.
Next let's take a look at the image uploaded by UEditor. The image style will be modified in the content presentation. However, the expression is also an img label, so global modification is problematic,
Therefore, you can only modify the code of the plug-in.
First, find the server segment file uploaded by the image. Here is the description of php.
Find Uploader. class. php 337 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, ); }
In this way, the returned json contains one more class attribute value.
One is to modify js
Find the following code in ueditor. all. js: 24461
Modify js
Function callback () {try {var link, json, loader, body = (iframe. contentDocument | iframe.content?#doc ument ). 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.doc ument. getElementById (loadingId); loader. setAttribute ('src', link); loader. setAttribute ('_ src', link); loader. setAttribute ('class', json. class | ''); // add the line code 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 );}
In this way, you can see that the uploaded images have multiple styles.
The above introduces how to set the style after Baidu ueditor uploads images, including Baidu ueditor content, and hope to help friends who are interested in PHP tutorials.