Home  >  Article  >  Backend Development  >  百度ueditor 上传图片后如何设置样式,ueditor上传图片_PHP教程

百度ueditor 上传图片后如何设置样式,ueditor上传图片_PHP教程

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

百度ueditor 上传图片后如何设置样式,ueditor上传图片

最近项目中遇到一个问题,UEditor上传图片后,在内容展示会修改图片样式。但是表情也是img标签,所以全局修改是有问题的,

所以只能着手修改一下插件的代码。

首先找到图片上传的服务器段文件。这里主要是php讲解

找到php目录下Uploader.class.php 337行

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,

       );
   }

这样返回的json 多一个class 属性的值

 

一种是修改js

找到ueditor.all.js 中 24461 如下代码

修改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);
}

 

这样上传下图片你就能看见上传的图片都多了个样式。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/918063.htmlTechArticle百度ueditor 上传图片后如何设置样式,ueditor上传图片 最近项目中遇到一个问题,UEditor上传图片后,在内容展示会修改图片样式。但是表情...
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