当前位置 博文首页 > 百度ueditor组件上传图片后如何设置img里的alt属性

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

    作者:admin 时间:2021-08-19 17:48

    百度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 && showErrorLoader(json.state);
    }
    }catch(er){
    showErrorLoader && showErrorLoader(me.getLang('simpleupload.loadError'));
    }
    form.reset();
    domUtils.un(iframe, 'load', callback);
    }

    jsjbwy
    下一篇:没有了