Merge pull request #1318 from onewhaleid/non-image-uploads

Handle non-image uploads correctly
This commit is contained in:
Bart Kamphorst
2018-10-07 14:40:43 +02:00
committed by GitHub
@@ -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) {