Ueditor编辑器图片上传自定义配置
来源:互联网 发布:单片机设计实例 编辑:程序博客网 时间:2024/06/09 21:45
Ueditor图片上传自定义配置
不使用自带后台配置
1、加载Ueditor编辑器所在的页面时,默认访问配置项serverUrl,访问这个请求后主要是为了返回配置信息。请求链接:serverUrl+”?action=config”
UeditorConfig.properties
#ueditor编辑器相关配置ueditor.imgePath=/upload#图片上传的actionueditor.imageActionName=uploadimageueditor.imageFieldName=upfileueditor.imageMaxSize=2048000#上传文件的类型ueditor.imageAllowFiles.str=.jpg,.pngueditor.imageCompressEnable=trueueditor.imageCompressBorder=1600ueditor.imageInsertAlign=none#图片显示的前缀ueditor.imageUrlPrefix=
类文件UeditorConfig.java
@Configuration@PropertySource(value = "classpath:config/ueditor.properties")public class UeditorConfig implements Serializable{ @Value("${ueditor.imgePath}") private String imgePath; @Value("${ueditor.imageActionName}") private String imageActionName; @Value("${ueditor.imageFieldName}") private String imageFieldName; @Value("${ueditor.imageMaxSize}") private int imageMaxSize; @Value("${ueditor.imageAllowFiles.str}") private String imageAllowFilesStr; private List<String> imageAllowFiles; @Value("${ueditor.imageCompressEnable}") private Boolean imageCompressEnable; @Value("${ueditor.imageCompressBorder}") private int imageCompressBorder; @Value("${ueditor.imageInsertAlign}") private String imageInsertAlign; @Value("${ueditor.imageUrlPrefix}") private String imageUrlPrefix; ...set和get方法
控制器UeditorController.java
因为.properties文件无法直接定义数组,所以需要转换
@RequestMapping(value = "/config") @ResponseBody public UeditorConfig config(){ ueditorConfig.setImageAllowFiles(Arrays.asList(ueditorConfig.getImageAllowFilesStr().split(","))); return ueditorConfig; }
只要后台正确返回如下的数据格式
{ "imageUrl": "http://localhost/ueditor/php/controller.php?action=uploadimage", "imagePath": "/ueditor/php/", "imageFieldName": "upfile", "imageMaxSize": 2048, "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"] "其他配置项...": "其他配置值..."}
2、加载成功,页面的图片上传按钮可以使用,选择完图片会请求serverUrl+”?action=uploadimage”,在方法中辨别action进而上传图片。
回传的数据格式要求:
rs.put("state", "SUCCESS");// UEDITOR的规则:不为SUCCESS则显示state的内容rs.put("url",fileUrls); //能访问到你现在图片的路径rs.put("title", "");rs.put("original", "");
改进方法:由于该配置项用于前端的编辑器,应该放在前端处理,做出如下改进:
在初始化代码var ue = UE.getEditor(‘editor’)下添加
UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;UE.Editor.prototype.getActionUrl = function (action) { if(action == 'config'){ //能找到config.json文件的路径 return "config.json"; }else if (action == 'uploadimage') { //上传图片的路径 return "/uploads"; } else { return this._bkGetActionUrl.call(this, action); }};
这样大部分问题都能够解决。
阅读全文
0 0
- Ueditor编辑器图片上传自定义配置
- 关于ueditor编辑器自定义图片上传方式
- Ueditor文本编辑器图片上传配置
- 百度编辑器Ueditor配置上传图片
- Ueditor富文本编辑器--上传图片自定义上传操作
- ueditor 编辑器,自定义图片上传及图片显示
- Ueditor 图片自定义上传
- 百度富文本编辑器UEditor自定义上传图片接口
- ueditor图片上传配置
- Ueditor 图片上传配置
- UEditor上传图片配置
- 百度编辑器ueditor上传图片及文件路径配置
- 百度Ueditor在线编辑器的配置和图片上传
- UEditor jsp版上传图片自定义路劲配置
- 百度UEditor上传图片配置
- 05 ueditor上传图片配置
- UEditor图片上传配置问题解决
- ueditor 图片上传路径配置
- win10 VPN里的ipv4的属性打不开,没办法去掉勾选“在远程网络上使用默认网关”如何解决?
- Linux RedHat7.0 上vsftp配置
- 并发库之CountDownLatch
- 1060. Are They Equal (25)
- recyclerView和retrofit的简单使用
- Ueditor编辑器图片上传自定义配置
- javascript--BOM概念
- EXCLUDE/INCLUDE
- python基础语法
- This page contains the following errors: error on line 1 at column 1: Extra content at the end of t
- java的HashMap类提供的方法
- ffmpeg音频处理——pcm格式与resample(重采样)
- CSS初始化样式
- blend画图技巧