Home  >  Article  >  Backend Development  >  Baidu ueditor sets the default width and height when uploading images

Baidu ueditor sets the default width and height when uploading images

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

 I’m also crazy about this. The official documentation of Baidu Editor is actually not very detailed. It only covers basic usage. I want to set the default size for uploaded images but I can’t find the corresponding documentation. After Jin Guo's disdainful efforts, the configuration was finally completed. In fact, it was very simple. I just added a line of code. . . . . 

Find ueditor.all.js under the root directory of the editor. It scares me when I open it. There are tens of thousands of lines of code, but don’t be afraid. Search: cllback() to find this function

 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');
                        }

Look at the comment part, in fact Just give the price attribute to the image uploaded by img! You can add attributes at will, just as you want, as casually as you like. If you pass by, if you learn something, give it a thumbs up! !

The above introduces how to set the default width and height when uploading images in Baidu ueditor, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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
Previous article:php writes data to excelNext article:php writes data to excel