百度ueditor 上传图片后怎么设置样式

WBOY
Release: 2016-06-13 12:10:40
Original
1233 people have browsed it

百度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,       );   }
Copy after login

这样返回的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);}
Copy after login

 

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

1楼jwblog
为什么我上传图片都显示失败了,是什么原因?图片已经上传到了服务器,可结果是失败,返回的也没图片。
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!