百度ueditor組件上傳圖片后里的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 && showErrorLoader(json.state);
                        }
                    }catch(er){
                        showErrorLoader && showErrorLoader(me.getLang('simpleupload.loadError'));
                    }
                    form.reset();
                    domUtils.un(iframe, 'load', callback);
                }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章