百度ueditor组件上传图片后如何设置img里的alt属性

发布时间:2022-04-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了百度ueditor组件上传图片后如何设置img里的alt属性脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

百度uedITor组件,使用上传图片后,自动将上传图片显示在编辑器中,也就是插入了一个<img>标签。并设置了一个alt属性,其值是上传图片时的本地路径。暂时没发现哪里可以配置这个值。在查看发布的内容时,看到alt的值是一个磁盘路径,有点别扭。

可以在编辑完内容,保存到数据库时过滤下,修改alt的内容,也可以直接修改

function callback(){
try{
VAR link, json, loader,
body = (iframe.contentDocument || iframe.contentWindow.document).body,
result = body.innerText || body.textContent || '';
JSON = (new Function("return " + result))();
link = me.options.imageUrlPRefix + json.url;
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.removeAttribute('id');
domUtils.removeClasses(loader, 'loadingclass');
} else {
showErrorLoader &amp;& showErrorLoader(json.state);
}
}catch(er){
showErrorLoader && showErrorLoader(me.getLang('simpleupload.loadError'));
}
form.reset();
domUtils.un(iframe, 'load', callback);
}

脚本宝典总结

以上是脚本宝典为你收集整理的百度ueditor组件上传图片后如何设置img里的alt属性全部内容,希望文章能够帮你解决百度ueditor组件上传图片后如何设置img里的alt属性所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。