Skip to content

Commit 6f515c4

Browse files
committed
Upload only images
1 parent d17c4ad commit 6f515c4

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
@@ -221,17 +221,25 @@
221221
};
222222

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

228237
loading.show();
229238

230-
var data = new FormData(),
231-
i = 0;
239+
var data = new FormData();
232240

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

237245
$.ajax({

0 commit comments

Comments
 (0)