kindEditor4.1.11版修改上传图片宽高(图片自适应)成功案例

找了数种方法,简单的复杂的,都无法将kindEditor4.1.11版上传图片宽高设置为自适应。
最终想到这个办法,直接在img src=路径里写死它。

修改kindeditor.js文件,约3260行:

insertimage : function(url, title, width, height, border, align) {
	title = _undef(title, '');
	border = _undef(border, 0);
	var html = '<img src="' + _escape(url) + '" data-ke-src="' + _escape(url) + '"  ';
	if (width) {
		html += 'width="' + _escape(width) + '" ';
	}
	if (height) {
		html += 'height="' + _escape(height) + '" ';
	}

修成为:

insertimage : function(url, title, width, height, border, align) {
	title = _undef(title, '');
	border = _undef(border, 0);
	var html = '<img src="' + _escape(url) + '" data-ke-src="' + _escape(url) + '" width="100%" ';	//这里加了  width="100%" (自适应),下面/*注释掉*/
	/*		if (width) {
		html += 'width="' + _escape(width) + '" ';
	}*/
	if (height) {
		html += 'height="' + _escape(height) + '" ';
	}

上传后 <img src="/upload/image/20201123/2020112323400352352.png" width="100%" alt="" /> 代码域自动写入 width=“100%”

第一次发布,希望能帮助一些像我这样执着的学者。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值