Home > php教程 > PHP开发 > body text

How to set the alt attribute in img after uploading pictures in Baidu ueditor component

高洛峰
Release: 2016-12-27 09:18:54
Original
1795 people have browsed it

Baidu ueditor component, after using the uploaded image, automatically displays the uploaded image in the editor, that is, inserting an tag. And set an alt attribute, whose value is the local path when uploading the image. I haven't found where to configure this value yet. When viewing the published content, I saw that the value of alt is a disk path, which is a bit awkward.

You can filter and modify the alt content after editing the content and save it to the database, or you can directly modify the source code

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);
}
Copy after login


More Baidu ueditor components For related articles on how to set the alt attribute in img after uploading images, please pay attention to the PHP Chinese website!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template