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"'))
						}
					}
				}				
			}
		);
	}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM