From 12f12fa6daf86de28874afbc6d3d296c703bfde5 Mon Sep 17 00:00:00 2001 From: Ryunosuke SATO Date: Fri, 11 Mar 2016 21:51:36 +0900 Subject: [PATCH] Upload only images --- src/bootstrap-markdown-editor.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/bootstrap-markdown-editor.js b/src/bootstrap-markdown-editor.js index 871e924..18e489e 100644 --- a/src/bootstrap-markdown-editor.js +++ b/src/bootstrap-markdown-editor.js @@ -232,17 +232,25 @@ }; function uploadFiles (url, files, editor, snippetManager, loading) { - if (! files.length) { - return; + var images = [], + i = 0; + + for (i = 0; i < files.length; i++) { + if (/^image\//.test(files[i].type)) { + images.push(files[i]); + } + } + + if (! images.length) { + return; } loading.show(); - var data = new FormData(), - i = 0; + var data = new FormData(); - for (i = 0; i < files.length; i++) { - data.append('file' + i, files[i]); + for (i = 0; i < images.length; i++) { + data.append('file' + i, images[i]); } $.ajax({