Heim  >  Artikel  >  Backend-Entwicklung  >  百度ueditor上传图片时设置默认宽高度

百度ueditor上传图片时设置默认宽高度

WBOY
WBOYOriginal
2016-08-08 09:22:291116Durchsuche

  我也是逼了dog了,百度编辑器官方文档其实做的很不详细,都是些基本的用法,想设置个上传图片默认尺寸都找不到相应文档。进过哥的不屑努力,终于是配置好了,其实也是很简单的,加了一行代码。。。。。 

 找到编辑器根目录下面的ueditor.all.js ,一打开吓到哥了,上万行代码,不过不要怕,search 一下 :cllback() 找到这个函数

 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.setAttribute('style','max-width:650px');//这里就是哥加入的代码
                            loader.removeAttribute('id');
                            domUtils.removeClasses(loader, 'loadingclass');
                        }

看看注释部分,其实就是给img 上传的图片价格属性就行了! 你可以任意增加属性,就这么任性,就是这么随意,走过路过,学到了的就给哥赞一个!!

以上就介绍了百度ueditor上传图片时设置默认宽高度,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn