How to set styles after Baidu ueditor uploads images

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.