zoukankan      html  css  js  c++  java
  • kindEditor上传图片自动限制大小

    1.后台图片上传路径/Public/kindeditor/php/upload_json.php;
    2.createHtml方法改为如下: 
     
    function createHtml(){
    		editor = KindEditor.create('#content{$nodeType}', {
    				safeMode: true,
    				resizeType: 1,
    				allowFileManager: true,
    				allowPreviewEmoticons: false,
    				items: [
    				'source','fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
    				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
    				'insertunorderedlist', 'image', 'multiimage'],
    				afterUpload : function(url, data, name) { //上传文件后执行的回调函数,必须为3个参数
    					if(name=="image" || name=="multiimage"){ //单个和批量上传图片时
    						var img = new Image(); img.src = url;
    						img.onload = function(){ //图片必须加载完成才能获取尺寸
    							if(img.width>330) editor.html(editor.html().replace('<img src="' + url + '"','<img src="' + url + '" width="330"'))
    						}
    					}
    				}				
    			}
    		);
    	}
    

      

  • 相关阅读:
    797. 所有可能的路径
    1286. 字母组合迭代器
    216. 组合总和 III
    77. 组合
    784. 字母大小写全排列
    90. 子集 II
    78. 子集
    47. 全排列 II
    46. 全排列
    40. 组合总和 II
  • 原文地址:https://www.cnblogs.com/benbenchen/p/8117541.html
Copyright © 2011-2022 走看看