關于移動手機端富文本編輯器qeditor圖片上傳改造

  日前項目需要在移動端增加富文本編輯,上網找了下,大多數都是針對pc版的,不太兼容手機,當然由于手機屏幕小等原因也限制富文本編輯器的眾多強大功能,所以要找的編輯器功能必須是精簡的。

  找了好久,發現qeditor比較精簡,操作簡單,唯一缺點是上傳圖片時只能填寫url,不能直接從手機上傳。

  針對這點,自己決定動手修改。

  修改思路:

    1、創建文件上傳輸入框

    2、點擊編輯器上傳圖片按鈕時,觸發文件輸入框點擊事件

    3、選擇圖片后異步上傳至服務器,返回圖片路徑

    4、編輯器插入img標簽,顯示圖片

  

  以下是修改過程:

  上圖了解下原來是怎么樣的,這個是qeditor的界面,qeditor的樣式可以自己修改:

  

  點擊上傳圖片按鈕后是彈框要求輸入圖片url的?:

  

  以下是改造后的效果,點擊圖片上傳按鈕顯示的是現在手機相冊圖片?:

?

  選擇后上傳圖片:

?

  qeditor的代碼只有200多行,相當簡潔,以下是原始代碼:

// Generated by CoffeeScript 1.6.3
/*
jquery.qeditor
==============This is a simple WYSIWYG editor with jQuery.## Author:Jason Lee <huacnlee@gmail.com>## Requirements:[jQuery](http://jquery.com)(Font-Awesome)[http://fortawesome.github.io/Font-Awesome/] - Toolbar icons## Usage:$("textarea").qeditor();and then you need filt the html tags,attributes in you content page.
In Rails application, you can use like this:<%= sanitize(@post.body,:tags => %w(strong b i u strike ol ul li address blockquote pre code br div p), :attributes => %w(src)) %>
*/var QEDITOR_ALLOW_TAGS_ON_PASTE, QEDITOR_DISABLE_ATTRIBUTES_ON_PASTE, QEDITOR_TOOLBAR_HTML;QEDITOR_TOOLBAR_HTML = "<div class=\"qeditor_toolbar\">\n  <a href=\"#\" data-action=\"bold\" class=\"qe-bold\"><span class=\"fa fa-bold\" title=\"Bold\"></span></a> \n  <a href=\"#\" data-action=\"italic\" class=\"qe-italic\"><span class=\"fa fa-italic\" title=\"Italic\"></span></a> \n  <a href=\"#\" data-action=\"underline\" class=\"qe-underline\"><span class=\"fa fa-underline\" title=\"Underline\"></span></a> \n  <a href=\"#\" data-action=\"strikethrough\" class=\"qe-strikethrough\"><span class=\"fa fa-strikethrough\" title=\"Strike-through\"></span></a>         \n  <span class=\"vline\"></span>\n  <span class=\"qe-icon qe-heading\">\n    <ul class=\"qe-menu\">\n      <li><a href=\"#\" data-name=\"h1\" class=\"qe-h1\">Heading 1</a></li>\n      <li><a href=\"#\" data-name=\"h2\" class=\"qe-h2\">Heading 2</a></li>\n      <li><a href=\"#\" data-name=\"h3\" class=\"qe-h3\">Heading 3</a></li>\n      <li><a href=\"#\" data-name=\"h4\" class=\"qe-h4\">Heading 4</a></li>\n      <li><a href=\"#\" data-name=\"h5\" class=\"qe-h5\">Heading 5</a></li>\n      <li><a href=\"#\" data-name=\"h6\" class=\"qe-h6\">Heading 6</a></li>\n      <li class=\"qe-hline\"></li>\n      <li><a href=\"#\" data-name=\"p\" class=\"qe-p\">Paragraph</a></li>\n    </ul>\n    <span class=\"icon fa fa-font\"></span>\n  </span>\n  <span class=\"vline\"></span>\n  <a href=\"#\" data-action=\"insertorderedlist\" class=\"qe-ol\"><span class=\"fa fa-list-ol\" title=\"Insert Ordered-list\"></span></a> \n  <a href=\"#\" data-action=\"insertunorderedlist\" class=\"qe-ul\"><span class=\"fa fa-list-ul\" title=\"Insert Unordered-list\"></span></a> \n  <a href=\"#\" data-action=\"indent\" class=\"qe-indent\"><span class=\"fa fa-indent\" title=\"Indent\"></span></a> \n  <a href=\"#\" data-action=\"outdent\" class=\"qe-outdent\"><span class=\"fa fa-outdent\" title=\"Outdent\"></span></a> \n  <span class=\"vline\"></span> \n  <a href=\"#\" data-action=\"insertHorizontalRule\" class=\"qe-hr\"><span class=\"fa fa-minus\" title=\"Insert Horizontal Rule\"></span></a> \n  <a href=\"#\" data-action=\"blockquote\" class=\"qe-blockquote\"><span class=\"fa fa-quote-left\" title=\"Blockquote\"></span></a> \n  <a href=\"#\" data-action=\"pre\" class=\"qe-pre\"><span class=\"fa fa-code\" title=\"Pre\"></span></a> \n  <a href=\"#\" data-action=\"createLink\" class=\"qe-link\"><span class=\"fa fa-link\" title=\"Create Link\" title=\"Create Link\"></span></a> \n  <a href=\"#\" data-action=\"insertimage\" class=\"qe-image\"><span class=\"fa fa-picture-o\" title=\"Insert Image\"></span></a> \n  <a href=\"#\" οnclick=\"return QEditor.toggleFullScreen(this);\" class=\"qe-fullscreen pull-right\"><span class=\"fa fa-arrows-alt\" title=\"Toggle Fullscreen\"></span></a> \n</div>";QEDITOR_ALLOW_TAGS_ON_PASTE = "div,p,ul,ol,li,hr,br,b,strong,i,em,img,h2,h3,h4,h5,h6,h7";QEDITOR_DISABLE_ATTRIBUTES_ON_PASTE = ["style", "class", "id", "name", "width", "height"];window.QEditor = {actions: ['bold', 'italic', 'underline', 'strikethrough', 'insertunorderedlist', 'insertorderedlist', 'blockquote', 'pre'],action: function(el, a, p) {var editor;editor = $(".qeditor_preview", $(el).parent().parent());editor.find(".qeditor_placeholder").remove();editor.focus();if (p === null) {p = false;}if (a === "blockquote" || a === "pre") {p = a;a = "formatBlock";}if (a === "createLink") {p = prompt("Type URL:");if (p.trim().length === 0) {return false;}} else if (a === "insertimage") {p = prompt("Image URL:");if (p.trim().length === 0) {return false;}}if (QEditor.state(a)) {document.execCommand(a, false, null);} else {document.execCommand(a, false, p);}QEditor.checkSectionState(editor);editor.change();return false;},state: function(action) {return document.queryCommandState(action) === true;},prompt: function(title) {var val;val = prompt(title);if (val) {return val;} else {return false;}},toggleFullScreen: function(el) {var border;border = $(el).parent().parent();if (border.data("qe-fullscreen") === "1") {QEditor.exitFullScreen();} else {QEditor.enterFullScreen(border);}return false;},enterFullScreen: function(border) {border.data("qe-fullscreen", "1").addClass("qeditor_fullscreen");border.find(".qeditor_preview").focus();return border.find(".qe-fullscreen span").attr("class", "fa fa-compress");},exitFullScreen: function() {return $(".qeditor_border").removeClass("qeditor_fullscreen").data("qe-fullscreen", "0").find(".qe-fullscreen span").attr("class", "fa fa-arrows-alt");},getCurrentContainerNode: function() {var containerNode, node;if (window.getSelection) {node = window.getSelection().anchorNode;containerNode = node.nodeType === 3 ? node.parentNode : node;}return containerNode;},checkSectionState: function(editor) {var a, link, _i, _len, _ref, _results;_ref = QEditor.actions;_results = [];for (_i = 0, _len = _ref.length; _i < _len; _i++) {a = _ref[_i];link = editor.parent().find(".qeditor_toolbar a[data-action=" + a + "]");if (QEditor.state(a)) {_results.push(link.addClass("qe-state-on"));} else {_results.push(link.removeClass("qe-state-on"));}}return _results;},version: function() {return "0.2.0";}
};(function($) {return $.fn.qeditor = function(options) {return this.each(function() {var currentVal, editor, obj, placeholder, qe_heading, toolbar;obj = $(this);obj.addClass("qeditor");editor = $('<div class="qeditor_preview clearfix" contentEditable="true"></div>');placeholder = $('<div class="qeditor_placeholder"></div>');$(document).keyup(function(e) {if (e.keyCode === 27) {return QEditor.exitFullScreen();}});document.execCommand('defaultParagraphSeparator', false, 'p');currentVal = obj.val();editor.html(currentVal);editor.addClass(obj.attr("class"));obj.after(editor);placeholder.text(obj.attr("placeholder"));editor.attr("placeholder", obj.attr("placeholder") || "");editor.append(placeholder);editor.focusin(function() {QEditor.checkSectionState(editor);return $(this).find(".qeditor_placeholder").remove();});editor.blur(function() {var t;t = $(this);QEditor.checkSectionState(editor);if (t.html().length === 0 || t.html() === "<br>" || t.html() === "<p></p>") {return $(this).html('<div class="qeditor_placeholder">' + $(this).attr("placeholder") + '</div>');}});editor.change(function() {var pobj, t;pobj = $(this);t = pobj.parent().find('.qeditor');return t.val(pobj.html());});editor.on("paste", function() {var txt;txt = $(this);return setTimeout(function() {var attrName, els, _i, _len;els = txt.find("*");for (_i = 0, _len = QEDITOR_DISABLE_ATTRIBUTES_ON_PASTE.length; _i < _len; _i++) {attrName = QEDITOR_DISABLE_ATTRIBUTES_ON_PASTE[_i];els.removeAttr(attrName);}els.find(":not(" + QEDITOR_ALLOW_TAGS_ON_PASTE + ")").contents().unwrap();txt.change();return true;}, 100);});editor.keyup(function(e) {QEditor.checkSectionState(editor);return $(this).change();});editor.on("click", function(e) {QEditor.checkSectionState(editor);return e.stopPropagation();});editor.keydown(function(e) {var node, nodeName;node = QEditor.getCurrentContainerNode();nodeName = "";if (node && node.nodeName) {nodeName = node.nodeName.toLowerCase();}if (e.keyCode === 13 && !(e.shiftKey || e.ctrlKey)) {if (nodeName === "blockquote" || nodeName === "pre") {e.stopPropagation();document.execCommand('InsertParagraph', false);document.execCommand("formatBlock", false, "p");document.execCommand('outdent', false);return false;}}});obj.hide();obj.wrap('<div class="qeditor_border"></div>');obj.after(editor);toolbar = $(QEDITOR_TOOLBAR_HTML);qe_heading = toolbar.find(".qe-heading");qe_heading.mouseenter(function() {$(this).addClass("hover");return $(this).find(".qe-menu").show();});qe_heading.mouseleave(function() {$(this).removeClass("hover");return $(this).find(".qe-menu").hide();});toolbar.find(".qe-heading .qe-menu a").click(function() {var link;link = $(this);link.parent().parent().hide();QEditor.action(this, "formatBlock", link.data("name"));return false;});toolbar.find("a[data-action]").click(function() {return QEditor.action(this, $(this).attr("data-action"));});return editor.before(toolbar);});};
})(jQuery);
View Code

  修改完成后的代碼:

// Generated by CoffeeScript 1.6.3
/*
jquery.qeditor
==============This is a simple WYSIWYG editor with jQuery.## Author:Jason Lee <huacnlee@gmail.com>## Requirements:[jQuery](http://jquery.com)(Font-Awesome)[http://fortawesome.github.io/Font-Awesome/] - Toolbar icons## Usage:$("textarea").qeditor();and then you need filt the html tags,attributes in you content page.
In Rails application, you can use like this:<%= sanitize(@post.body,:tags => %w(strong b i u strike ol ul li address blockquote pre code br div p), :attributes => %w(src)) %>
*/var QEDITOR_ALLOW_TAGS_ON_PASTE, QEDITOR_DISABLE_ATTRIBUTES_ON_PASTE, QEDITOR_TOOLBAR_HTML;QEDITOR_TOOLBAR_HTML = "<div class=\"qeditor_toolbar\">\n  <a href=\"#\" data-action=\"bold\" class=\"qe-bold\"><span class=\"fa fa-bold\" title=\"Bold\"></span></a> \n  <a href=\"#\" data-action=\"italic\" class=\"qe-italic\"><span class=\"fa fa-italic\" title=\"Italic\"></span></a> \n  <a href=\"#\" data-action=\"underline\" class=\"qe-underline\"><span class=\"fa fa-underline\" title=\"Underline\"></span></a> \n  <a href=\"#\" data-action=\"strikethrough\" class=\"qe-strikethrough\"><span class=\"fa fa-strikethrough\" title=\"Strike-through\"></span></a>         \n  <span class=\"vline\"></span>\n  <span class=\"qe-icon qe-heading\">\n    <ul class=\"qe-menu\">\n      <li><a href=\"#\" data-name=\"h1\" class=\"qe-h1\">Heading 1</a></li>\n      <li><a href=\"#\" data-name=\"h2\" class=\"qe-h2\">Heading 2</a></li>\n      <li><a href=\"#\" data-name=\"h3\" class=\"qe-h3\">Heading 3</a></li>\n      <li><a href=\"#\" data-name=\"h4\" class=\"qe-h4\">Heading 4</a></li>\n      <li><a href=\"#\" data-name=\"h5\" class=\"qe-h5\">Heading 5</a></li>\n      <li><a href=\"#\" data-name=\"h6\" class=\"qe-h6\">Heading 6</a></li>\n      <li class=\"qe-hline\"></li>\n      <li><a href=\"#\" data-name=\"p\" class=\"qe-p\">Paragraph</a></li>\n    </ul>\n    <span class=\"icon fa fa-font\"></span>\n  </span>\n  <span class=\"vline\"></span>\n  <a href=\"#\" data-action=\"insertorderedlist\" class=\"qe-ol\"><span class=\"fa fa-list-ol\" title=\"Insert Ordered-list\"></span></a> \n  <a href=\"#\" data-action=\"insertunorderedlist\" class=\"qe-ul\"><span class=\"fa fa-list-ul\" title=\"Insert Unordered-list\"></span></a> \n  <a href=\"#\" data-action=\"indent\" class=\"qe-indent\"><span class=\"fa fa-indent\" title=\"Indent\"></span></a> \n  <a href=\"#\" data-action=\"outdent\" class=\"qe-outdent\"><span class=\"fa fa-outdent\" title=\"Outdent\"></span></a> \n  <span class=\"vline\"></span> \n  <a href=\"#\" data-action=\"insertHorizontalRule\" class=\"qe-hr\"><span class=\"fa fa-minus\" title=\"Insert Horizontal Rule\"></span></a> \n  <a href=\"#\" data-action=\"blockquote\" class=\"qe-blockquote\"><span class=\"fa fa-quote-left\" title=\"Blockquote\"></span></a> \n  <a href=\"#\" data-action=\"pre\" class=\"qe-pre\"><span class=\"fa fa-code\" title=\"Pre\"></span></a> \n  <a href=\"#\" data-action=\"createLink\" class=\"qe-link\"><span class=\"fa fa-link\" title=\"Create Link\" title=\"Create Link\"></span></a> \n  <a href=\"#\" data-action=\"insertimage\" class=\"qe-image\"><span class=\"fa fa-picture-o\" title=\"Insert Image\"></span></a> \n <a href=\"#\" οnclick=\"return QEditor.toggleFullScreen(this);\" class=\"qe-fullscreen pull-right\"><span class=\"fa fa-arrows-alt\" title=\"Toggle Fullscreen\"></span></a> \n</div>";QEDITOR_ALLOW_TAGS_ON_PASTE = "div,p,ul,ol,li,hr,br,b,strong,i,em,img,h2,h3,h4,h5,h6,h7";QEDITOR_DISABLE_ATTRIBUTES_ON_PASTE = ["style", "class", "id", "name", "width", "height"];window.QEditor = {actions: ['bold', 'italic', 'underline', 'strikethrough', 'insertunorderedlist', 'insertorderedlist', 'blockquote', 'pre'],action: function(el, a, p) {var editor;editor = $(".qeditor_preview", $(el).parent().parent());editor.find(".qeditor_placeholder").remove();editor.focus();if (p === null) {p = false;}if (a === "blockquote" || a === "pre") {p = a;a = "formatBlock";}if (a === "createLink") {p = prompt("Type URL:");if (p.trim().length === 0) {return false;}} else if (a === "insertimage") {//p = prompt("Image URL:");//TODOvar input;if(document.getElementById('inImgId')){input = document.getElementById('inImgId');}else{input = document.createElement('input');input.setAttribute('id', 'inImgId');input.setAttribute('type', 'file');input.setAttribute('name', 'file');input.setAttribute('accept', 'image/gif, image/jpeg, image/jpg, image/png');document.body.appendChild(input);input.style.display = 'none';}input.click();input.onchange = function(){if(!input.value){return;}var fd = new FormData();var file;file = input.files[0];fd.append('file', file);$.ajax({url : window.location.protocol + '//' + window.location.host + '/weixin/uploadArticlePic',data : fd,processData : false,contentType : false,enctype : 'multipart/form-data',type : 'POST',success : function(data) {var json = JSON.parse(data);if (json.success) {QEditor.imageChange(json.data);} else {alert(json.message);}}});}if (p == null || p.trim().length === 0) {return false;}}if (QEditor.state(a)) {document.execCommand(a, false, null);} else {document.execCommand(a, false, p);}QEditor.checkSectionState(editor);editor.change();return false;},state: function(action) {return document.queryCommandState(action) === true;},prompt: function(title) {var val;val = prompt(title);if (val) {return val;} else {return false;}},toggleFullScreen: function(el) {var border;border = $(el).parent().parent();if (border.data("qe-fullscreen") === "1") {QEditor.exitFullScreen();} else {QEditor.enterFullScreen(border);}return false;},enterFullScreen: function(border) {border.data("qe-fullscreen", "1").addClass("qeditor_fullscreen");border.find(".qeditor_preview").focus();return border.find(".qe-fullscreen span").attr("class", "fa fa-compress");},exitFullScreen: function() {return $(".qeditor_border").removeClass("qeditor_fullscreen").data("qe-fullscreen", "0").find(".qe-fullscreen span").attr("class", "fa fa-arrows-alt");},getCurrentContainerNode: function() {var containerNode, node;if (window.getSelection) {node = window.getSelection().anchorNode;containerNode = node.nodeType === 3 ? node.parentNode : node;}return containerNode;},checkSectionState: function(editor) {var a, link, _i, _len, _ref, _results;_ref = QEditor.actions;_results = [];for (_i = 0, _len = _ref.length; _i < _len; _i++) {a = _ref[_i];link = editor.parent().find(".qeditor_toolbar a[data-action=" + a + "]");if (QEditor.state(a)) {_results.push(link.addClass("qe-state-on"));} else {_results.push(link.removeClass("qe-state-on"));}}return _results;},imageChange: function(imgUrl) {var editor = $(".qeditor_preview", $(".qeditor_border"));editor.focus();document.execCommand("insertimage", false, imgUrl);QEditor.checkSectionState(editor);editor.change();},version: function() {return "0.2.0";}
};(function($) {return $.fn.qeditor = function(params) {// 控制上傳圖片按鈕顯示與否 Add by C.Q 20160803var defaults = {showImage: true // true:顯示上傳圖片按鈕;false:不顯示
    };params = $.extend({}, defaults, params);return this.each(function() {var currentVal, editor, obj, placeholder, qe_heading, toolbar;obj = $(this);obj.addClass("qeditor");editor = $('<div class="qeditor_preview clearfix" contentEditable="true"></div>');placeholder = $('<div class="qeditor_placeholder"></div>');$(document).keyup(function(e) {if (e.keyCode === 27) {return QEditor.exitFullScreen();}});document.execCommand('defaultParagraphSeparator', false, 'p');currentVal = obj.val();editor.html(currentVal);editor.addClass(obj.attr("class"));obj.after(editor);placeholder.text(obj.attr("placeholder"));editor.attr("placeholder", obj.attr("placeholder") || "");editor.append(placeholder);editor.focusin(function() {QEditor.checkSectionState(editor);return $(this).find(".qeditor_placeholder").remove();});editor.blur(function() {var t;t = $(this);QEditor.checkSectionState(editor);if (t.html().length === 0 || t.html() === "<br>" || t.html() === "<p></p>") {return $(this).html('<div class="qeditor_placeholder">' + $(this).attr("placeholder") + '</div>');}});editor.change(function() {var pobj, t;pobj = $(this);t = pobj.parent().find('.qeditor');return t.val(pobj.html());});editor.on("paste", function() {var txt;txt = $(this);return setTimeout(function() {var attrName, els, _i, _len;els = txt.find("*");for (_i = 0, _len = QEDITOR_DISABLE_ATTRIBUTES_ON_PASTE.length; _i < _len; _i++) {attrName = QEDITOR_DISABLE_ATTRIBUTES_ON_PASTE[_i];els.removeAttr(attrName);}els.find(":not(" + QEDITOR_ALLOW_TAGS_ON_PASTE + ")").contents().unwrap();txt.change();return true;}, 100);});editor.keyup(function(e) {QEditor.checkSectionState(editor);return $(this).change();});editor.on("click", function(e) {QEditor.checkSectionState(editor);return e.stopPropagation();});editor.keydown(function(e) {var node, nodeName;node = QEditor.getCurrentContainerNode();nodeName = "";if (node && node.nodeName) {nodeName = node.nodeName.toLowerCase();}if (e.keyCode === 13 && !(e.shiftKey || e.ctrlKey)) {if (nodeName === "blockquote" || nodeName === "pre") {e.stopPropagation();document.execCommand('InsertParagraph', false);document.execCommand("formatBlock", false, "p");document.execCommand('outdent', false);return false;}}});obj.hide();obj.wrap('<div class="qeditor_border"></div>');obj.after(editor);// 控制圖片顯示與否 Add by C.Q 20160803if (params.showImage == false) {QEDITOR_TOOLBAR_HTML = QEDITOR_TOOLBAR_HTML.replace('<a href="#" data-action="insertimage" class="qe-image"><span class="fa fa-picture-o" title="Insert Image"></span></a>', "");}toolbar = $(QEDITOR_TOOLBAR_HTML);qe_heading = toolbar.find(".qe-heading");qe_heading.mouseenter(function() {$(this).addClass("hover");return $(this).find(".qe-menu").show();});qe_heading.mouseleave(function() {$(this).removeClass("hover");return $(this).find(".qe-menu").hide();});toolbar.find(".qe-heading .qe-menu a").click(function() {var link;link = $(this);link.parent().parent().hide();QEditor.action(this, "formatBlock", link.data("name"));return false;});toolbar.find("a[data-action]").click(function() {return QEditor.action(this, $(this).attr("data-action"));});return editor.before(toolbar);});};
})(jQuery);
View Code

  在這里我就不解讀其它的代碼功能了,主要講解下修改部分:

  1、在window.QEditor的action方法中有一處判斷是否點擊圖片上傳按鈕的

else if (a === "insertimage") {p = prompt("Image URL:");if (p.trim().length === 0) {return false;}}

  從這里入手,根據思路進行相應改造

else if (a === "insertimage") {//p = prompt("Image URL:");var input;if(document.getElementById('inImgId')){input = document.getElementById('inImgId');}else{input = document.createElement('input');input.setAttribute('id', 'inImgId');input.setAttribute('type', 'file');input.setAttribute('name', 'file');input.setAttribute('accept', 'image/gif, image/jpeg, image/jpg, image/png');document.body.appendChild(input);input.style.display = 'none';}input.click();input.onchange = function(){if(!input.value){return;}var fd = new FormData();var file;file = input.files[0];fd.append('file', file);$.ajax({url : window.location.protocol + '//' + window.location.host + '/weixin/uploadArticlePic',data : fd,processData : false,contentType : false,enctype : 'multipart/form-data',type : 'POST',success : function(data) {var json = JSON.parse(data);if (json.success) {QEditor.imageChange(json.data);} else {alert(json.message);}}});}if (p == null || p.trim().length === 0) {return false;}}

注意到代碼中上傳圖片成功后執行的?QEditor.imageChange(json.data)方法。

?這是我加上去的,目的是使編輯器插入圖片,并改變編輯器的值(注意qeditor是由textarea和預覽div組成,插入圖片是插入到預覽div中,并不存在textarea中,而取值卻是從textarea中取,所以原作者以增加change()方法解決此問題,本人加入的QEditor.imageChange(json.data)同樣是為解決這個問題)

imageChange: function(imgUrl) {var editor = $(".qeditor_preview", $(".qeditor_border"));editor.focus();document.execCommand("insertimage", false, imgUrl);QEditor.checkSectionState(editor);editor.change();}

至此修改完畢。

經測試。。。。

出現各種各樣問題。。。。。圖片旋轉的、ip4拍照閃退、圖片過大等。。。

后續優化:

  1、加入圖片壓縮,減少服務器帶寬壓力

  2、解決圖片旋轉問題

  3、加入進度條

  4、等

?

轉載于:https://www.cnblogs.com/theroad/p/5736201.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/457486.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/457486.shtml
英文地址,請注明出處:http://en.pswp.cn/news/457486.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【python】生成器

生成器 直接總結 創建生成器的方法 生成器表達式&#xff1a;(i for i in [1, 2])yield: 函數中出現yield這個函數就是生成器&#xff0c;函數&#xff08;生成器&#xff09;執行到yield時會返回yield后面的值&#xff0c;并暫停&#xff0c;知道下次被喚醒后會從暫停處接著…

python redis 性能測試臺_Redis性能測試

Redis 性能測試Redis 性能測試是通過同時執行多個命令實現的。Redis性能測試主要是通過src文件夾下的redis-benchmark來實現(Linux系統下)語法redis 性能測試的基本命令如下&#xff1a;redis-benchmark [option] [option value]實例以下實例同時執行 10000 個請求來檢測性能&a…

Java IO 系統

Java IO系統 File類 用來處理文件目錄&#xff0c;既可以代表一個特定文件的名稱&#xff0c;也可以代表一組文件的名稱&#xff0c;如果代表的是一個文件組&#xff0c;可以調用File.list()方法返回一個字符數組。 list()不傳遞任何參數時返回該目錄下所有文件或文件名的字…

Linux Crontab 任務管理工具命令以及示例

Crontab 是 Linux 平臺下的一款用于循環執行例行任務的工具,Linux 系統由 cron (crond) 這個系統服務來控制任務 , Linux系統本來就有很多的計劃任務需要啟動 , 所以這個系統服務是默認開機啟動的 。 Linux 為使用者提供的計劃任務的命令就是 Crontab Crontab 是 Linux 下用來周…

Linux 網絡編程詳解一(IP套接字結構體、網絡字節序,地址轉換函數)

IPv4套接字地址結構 struct sockaddr_in {uint8_t sinlen;&#xff08;4個字節&#xff09;sa_family_t sin_family;&#xff08;4個字節&#xff09;in_port_t sin_port;&#xff08;2個字節&#xff09;struct in_addr sin_addr;&#xff08;4個字節&#xff09;char sin_zer…

地籍cad的lisp程序大集合_AutoCAD-LISP程序100例

{:soso_e179:}AutoCAD-LISP程序100例.JPG (143.82 KB, 下載次數: 28)2011-10-18 14:42 上傳有說明很好&#xff01;頂如果您使用 AutoCAD,下面的內容對您一定有幫助。在某些方面能大大提高您的工作效率。下面的程序均以源程序方式給出&#xff0c;您可以使用、參考、修改它。bg…

javascript中數組的22種方法

前面的話數組總共有22種方法&#xff0c;本文將其分為對象繼承方法、數組轉換方法、棧和隊列方法、數組排序方法、數組拼接方法、創建子數組方法、數組刪改方法、數組位置方法、數組歸并方法和數組迭代方法共10類來進行詳細介紹對象繼承方法數組是一種特殊的對象&#xff0c;繼…

javascript/jquery高度寬度詳情解說分析

為什么80%的碼農都做不了架構師&#xff1f;>>> 一、window對象表示瀏覽器中打開的窗口 二、window對象可以省略 一、document對象是window對象的一部分 二、瀏覽器的HTML文檔成為Document對象 window.location和document.location window對象的location屬性引用的…

農用地包括哪些地類_土地地類一覽表

一級類二級類三級類含義編號三大類名稱編號名稱編號名稱1農用地指直接用于農業生產的土地&#xff0c;包括耕地&#xff0c;園地&#xff0c;林地&#xff0c;牧草地及其他的農業用地11耕地指種植農作物、土地&#xff0c;包括熟地、新開發復墾整理地&#xff0c;休閑地、輪歇地…

紅黑樹插入時的自平衡

紅黑樹插入時的自平衡 紅黑樹實質上是一棵自平衡的二叉查找樹&#xff0c;引入帶顏色的節點也是為了方便在進行插入或刪除操作時&#xff0c;如果破壞了二叉查找樹的平衡性能通過一系列變換保持平衡。 紅黑樹的性質 每個節點要么是紅色&#xff0c;要么是黑色根節點必須是黑…

說一下自己對于 Linux 哲學的理解

查閱了一些資料&#xff0c;官方的哲學思想貌似是&#xff1a; 一切皆文件由眾多單一目的的小程序&#xff0c;一個程序只實現一個功能&#xff0c;多個程序組合完成復雜任務文本文件保存配置信息盡量避免與用戶交互什么&#xff0c;你問我的理解&#xff1f;哲學思想&#xff…

UWP學習記錄

微軟{X:Bind}、{Binding}資料網站 &#xff1a; https://msdn.microsoft.com/windows/uwp/xaml-platform/x-bind-markup-extension在View的ItemTemplate中綁定ViewModel的方法&#xff1a;1 <ItemsControl Name"XX" ItemsSource"{x:Bind VM.XXModels,ModeOne…

dw1000信標碼_DW1000方案工牌型UWB標簽,助力10厘米高精度室內定位!

DW1000方案工牌型UWB標簽&#xff0c;助力10厘米高精度室內定位&#xff01;發布日期&#xff1a;2019-04-01 瀏覽次數&#xff1a;244次微能信息(95power)推出一款工牌型UWB標簽VDU1510 &#xff0c;廣泛應用于超寬帶UWB定位系統&#xff0c;最高可實現10cm高精度人員定位。工…

【Java】HashMap源碼(1.7)

Life is not a ridiculous number of life, the meaning of life lies in life itself HashMap源碼 散列集 數組和鏈表可以保持元素插入的順序&#xff0c;對數組來說&#xff0c;他的優點是擁有連續的存儲空間&#xff0c;因此可以使用元素下標快速訪問&#xff0c;但缺點在…

Docker 基本用法

1.安裝&#xff1a; wget http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm rpm -ivh epel-release-6-8.noarch.rpm yum install docker-io -y2.獲取鏡像 pull docker pull ubuntu docker pull ubuntu:14.043.運行這個鏡像&#xff0c;在其中運行bash應用…

畫刷的使用

1.畫刷的定義&#xff1a; HBRUSH hBrush; windows 自定義的畫刷&#xff1a; WHITE_BRUSH、LTGRAY_BRUSH、GRAY_BRUSH、DKGRAY_BRUSH、BLACK_BRUSH和NULL_BRUSH &#xff08;也叫HOLLOW_BRUSH&#xff09; 獲取方法如下&#xff1a; hBrush (HBRUSH) GetStockObject (GRAY_BR…

dataframe 控對象_iOS知識 - 常用小技巧大雜燴

1&#xff0c;打印View所有子視圖po [[self view]recursiveDescription]2&#xff0c;layoutSubviews調用的調用時機* 當視圖第一次顯示的時候會被調用。* 添加子視圖也會調用這個方法。* 當本視圖的大小發生改變的時候是會調用的。* 當子視圖的frame發生改變的時候是會調用的。…

【Java】jdk 1.8 新特性——Lambda表達式

Lambda表達式 jdk 1.8 新加入的特性&#xff0c;簡化了簡單接口的實現 函數式接口 函數式中只有一個待實現的方法&#xff0c;可以使用FunctionalInterface注解標注函數式接口.這個接口中只能有一個待實現的方法&#xff0c;但可以包含默認方法&#xff0c;靜態方法以及Obje…

【Todo】Java8新特性學習

參考這篇文章吧&#xff1a; http://blog.csdn.net/vchen_hao/article/details/53301073 還有一個系列轉載于:https://www.cnblogs.com/charlesblc/p/6123380.html

jsp調整字體大小font_html font標簽如何設置字體大小?

首先我們先來看看htmlfont標簽是如何來設置字體大小的&#xff1a;都只到htmlfont標簽是個專門用來設置字體的標簽&#xff0c;雖然在html5中用的會很少(因為都用css樣式來設置font標簽里面的屬性)&#xff0c;但是個人覺得font標簽還是相當強大的標簽的&#xff0c;為什么這么…