Prevent upload of non-image files already on client side

There is no need to send the file to the server if it is not an image
file (it will be rejected anyway).

Change-Id: I2e422b6678e62e8e50dfcca077c280db237b3ab0
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/imagare/client/UploadByFileSelection.java b/src/main/java/com/googlesource/gerrit/plugins/imagare/client/UploadByFileSelection.java
index d7ede85..8c78e66 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/imagare/client/UploadByFileSelection.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/imagare/client/UploadByFileSelection.java
@@ -41,7 +41,11 @@
       if (f) {
         var r = new FileReader();
         r.onload = function(e) {
-          @com.googlesource.gerrit.plugins.imagare.client.ImageUploader::uploadImage(Ljava/lang/String;Ljava/lang/String;)(e.target.result, f.name);
+          if (f.type.match('image/.*')) {
+            @com.googlesource.gerrit.plugins.imagare.client.ImageUploader::uploadImage(Ljava/lang/String;Ljava/lang/String;)(e.target.result, f.name);
+          } else {
+            $wnd.Gerrit.showError('no image file');
+          }
         }
         r.readAsDataURL(f);
       }