我用的是最新版本KindEditor 4.1.7
说说两个小功能,上传图片和上传文件
1.上传图片的时候我们通常不用网络图片,这时候我们可以去掉它,在初始化的时候加上这句:
allowImageRemote : false,
?查看KindEditor源码,kindeditor-4.1.7/plugins/image/image.js
KindEditor.plugin('image', function(K) { var self = this, name = 'image', allowImageUpload = K.undef(self.allowImageUpload, true), allowImageRemote = K.undef(self.allowImageRemote, true), formatUploadUrl = K.undef(self.formatUploadUrl, true), allowFileManager = K.undef(self.allowFileManager, false), uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'), imageTabIndex = K.undef(self.imageTabIndex, 0), imgPath = self.pluginsPath + 'image/images/', extraParams = K.undef(self.extraFileUploadParams, {}), filePostName = K.undef(self.filePostName, 'imgFile'), fillDescAfterUploadImage = K.undef(self.fillDescAfterUploadImage, false), lang = self.lang(name + '.');
?这是初始化的时候的一些开关
2.上传文件成功后如果不添加文件说明,它就会默认你给文件的路径作为说明,这一点很不爽,我们可以把原文件名称作为文件说明,修改如下:
?查看KindEditor源码,kindeditor-4.1.7/plugins/insertfile/insertfile.js,找到下面这句代码
if (allowFileUpload) { var uploadbutton = K.uploadbutton({ button : K('.ke-upload-button', div)[0], fieldName : filePostName, url : K.addParam(uploadJson, 'dir=file'), extraParams : extraParams, afterUpload : function(data) { dialog.hideLoading(); if (data.error === 0) { var url = data.url; if (formatUploadUrl) { url = K.formatUrl(url, 'absolute'); } urlBox.val(url);
?在后面添加K('[name="title"]', div).val(data.tips); 就是对文件说明进行赋值
?注:tips是json返回的文件名称。(本人用的是play框架,欢迎指教!)
?转载请注明出处:http://maccter.iteye.com/admin/blogs/1915586
?
?