百度编辑器(Ueditor)上传本地图片加alt属性

打开百度编辑器(Ueditor)目录/dialogs/image/image.js文件,查找“插入多张图片”

修改以下代码:

    /**
     * 插入多张图片
     */
    function insertBatch() {
        if (imageUrls.length < 1) return;
        var imgObjs = [],
            align = findFocus("localFloat", "name");
        for (var i = 0, ci; ci = imageUrls[i++];) {
            var tmpObj = {};
            tmpObj.title = ci.title;
            tmpObj.alt = ci.title;
            tmpObj.floatStyle = align;
            //修正显示时候的地址数据,如果后台返回的是图片的绝对地址,那么此处无需修正
            tmpObj._src = tmpObj.src = editor.options.imagePath + ci.url;
            imgObjs.push(tmpObj);
        }
        insertImage(imgObjs);
        hideFlash();
    }

即在tmpObj.title = ci.title;下面添加tmpObj.alt = ci.title;,好了赶快打开编辑器试下吧

相关阅读:http://www.xker.com/page/e2015/0411/175419.html

201402更新:

如果你在ueditor.config.js配置文件filterRules中定义了图片img标签的过滤规则,需要在这里设置下:

                        img: function (node) {
                            var src = node.getAttr('src');
                            var alt = node.getAttr('title');
                            var title = node.getAttr('title');
                            node.setAttr();
                            node.setAttr({'src':src})
                            node.setAttr({'alt':alt})
                            node.setAttr({'title':title})
                        },