百度富文本上传图片后样式崩塌

🔥博客主页 : 破浪前进

🔖系列专栏 : Vue、React、PHP

❤️感谢大家点赞👍收藏⭐评论✍️


问题描述:上传图片后,图片会变得很大,当点击的时候更是会顶开整个的容器的高跟宽

原因:百度富文本为了呈现给用户良好的使用导致没有写死宽高,本地多大上传后就是多大

解决方法:在同时修改两个文件分别在

javascript 复制代码
loader.setAttribute('width','100%');//图片宽度100%
loader.setAttribute('height','auto');//图片高度auto

23774行(不一定)和24533(不一定),不行就搜索

javascript 复制代码
		loadingHtml = '<img class="loadingclass" id="' + loadingId + '" src="' +
                me.options.themePath + me.options.theme +
                '/images/spacer.gif" title="' + (me.getLang('autoupload.loading') || '') + '" >';
            successHandler = function(data) {
                var link = urlPrefix + data.url,
                    loader = me.document.getElementById(loadingId);
                if (loader) {
                    loader.setAttribute('src', link);
                    loader.setAttribute('_src', link);
                    loader.setAttribute('title', data.title || '');
                    loader.setAttribute('alt', data.original || '');
                    loader.setAttribute('width','100%');//图片宽度100%
  				loader.setAttribute('height','auto');//图片高度auto
                    loader.removeAttribute('id');
                    domUtils.removeClasses(loader, 'loadingclass');
                }
            };
javascript 复制代码
					if(json.state == 'SUCCESS' && json.url) {
                            loader = me.document.getElementById(loadingId);
                            loader.setAttribute('src', link);
                            loader.setAttribute('_src', link);
                            loader.setAttribute('title', json.title || '');
                            loader.setAttribute('alt', json.original || '');
                            loader.setAttribute('width','100%');//图片宽度100%
  						loader.setAttribute('height','auto');//图片高度auto
                            loader.removeAttribute('id');
                            domUtils.removeClasses(loader, 'loadingclass');
                        } else {
                            showErrorLoader && showErrorLoader(json.state);
                        }
相关推荐
AiMan17 分钟前
腾讯ima还是不可以导出左侧所有对话,只能单条导出,方法不对吗
前端
去伪存真20 分钟前
并发量一高就装死?Agent 全链路“防猝死”手册
前端·agent
Moment22 分钟前
AI 编程时代,聊聊我的 Mac mini 双屏桌面
前端·后端
AiMan33 分钟前
先确认能不能一次把Microsofat Copilot所有内容打包一个文件导出
前端
总要学点什么37 分钟前
第97篇:三维数据加载-城市建筑白模自定义着色器——让一条光带沿高度扫上去,快慢却由帧率说了算
前端·gis·webgl·cesium·着色器·空间分析·白模
上海懒图科技1 小时前
工厂厂区电子地图定位导航:厂区人车精准定位,安全合规双保障
前端·arcgis·vue
西安小哥1 小时前
端侧跑大模型,真正的门槛不在参数量:一次 596 秒到 10 秒的压缩路径复盘
前端·人工智能
陈随易2 小时前
Cloudflare 出钱,Vite 团队挑人,44 个维护者分 30 万美元
前端·后端·程序员
恋猫de小郭2 小时前
Flutter THLC 的 WebView 滚动终于从 70 FPS 提升到 120 FPS
android·前端·flutter
严肃小白兔3 小时前
TanStack Router 更新构建工具链:Node.js 兼容性、路由分割与前端工程实践
前端·node.js·状态模式