Handle non-image uploads correctly

This commit is contained in:
Dan Howe
2018-09-19 22:48:09 +10:00
parent 676fb474b9
commit 3060a3576f
@@ -217,7 +217,15 @@
type: 'POST',
success: function(){
$editorBody.removeClass('uploading');
var text = '[[/' + uploadDest + '/' + file.name + ']]';
var ext = file.name.split('.').pop().toLowerCase()
var image_ext = ['jpg', 'jpeg', 'tif', 'tiff', 'png', 'gif', 'svg', 'bmp']
// Link directly to image files
if ((image_ext.indexOf(ext) > -1)) {
var text = '[[/' + uploadDest + '/' + file.name + ']]';
} else {
// Add file name to tag for non-image files, to avoid broken image thumbnail
var text = '[[' + file.name + '|/' + uploadDest + '/' + file.name + ']]';
}
window.ace_editor.insert(text);
},
error: function(r, textStatus) {