diff --git a/lib/gollum/public/gollum/javascript/editor/gollum.editor.js b/lib/gollum/public/gollum/javascript/editor/gollum.editor.js
index <HASH>..<HASH> 100755
--- a/lib/gollum/public/gollum/javascript/editor/gollum.editor.js
+++ b/lib/gollum/public/gollum/javascript/editor/gollum.editor.js
@@ -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) {
Handle non-image uploads correctly