Skip to content

Commit 0fd3e87

Browse files
committed
Upload only images
1 parent 36d7a6a commit 0fd3e87

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/bootstrap-markdown-editor.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,25 @@
220220
};
221221

222222
function uploadFiles (url, files, editor, snippetManager, loading) {
223-
if (!files.length) {
223+
var images = [],
224+
i = 0;
225+
226+
for (i = 0; i < files.length; i++) {
227+
if (/^image\//.test(files[i].type)) {
228+
images.push(files[i]);
229+
}
230+
}
231+
232+
if (!images.length) {
224233
return;
225234
}
226235

227236
loading.show();
228237

229-
var data = new FormData(),
230-
i = 0;
238+
var data = new FormData();
231239

232-
for (i = 0; i < files.length; i++) {
233-
data.append('file' + i, files[i]);
240+
for (i = 0; i < images.length; i++) {
241+
data.append('file' + i, images[i]);
234242
}
235243

236244
$.ajax({

0 commit comments

Comments
 (0)