]> BookStack Code Mirror - bookstack/commitdiff
Merge branch 'bug/gif-image-740' of git://github.com/Abijeet/BookStack
authorDan Brown <redacted>
Sat, 24 Mar 2018 14:54:50 +0000 (14:54 +0000)
committerDan Brown <redacted>
Sat, 24 Mar 2018 14:54:50 +0000 (14:54 +0000)
Also removed console.logs in dropzone.js

app/Services/ImageService.php
resources/assets/js/vues/components/dropzone.js

index 9755ea3072b0baa652e8d381c55e7dc2264b9635..6686082eefea30073229496509a38c6ca0c795ac 100644 (file)
@@ -170,6 +170,15 @@ class ImageService extends UploadService
         return $image->path;
     }
 
+    /**
+     * Checks if the image is a gif. Returns true if it is, else false.
+     * @param Image $image
+     * @return boolean
+     */
+    protected function isGif(Image $image) {
+        return strtolower(pathinfo($this->getPath($image), PATHINFO_EXTENSION)) === 'gif';
+    }
+
     /**
      * Get the thumbnail for an image.
      * If $keepRatio is true only the width will be used.
@@ -184,6 +193,10 @@ class ImageService extends UploadService
      */
     public function getThumbnail(Image $image, $width = 220, $height = 220, $keepRatio = false)
     {
+        if ($keepRatio && $this->isGif($image)) {
+            return $this->getPublicUrl($this->getPath($image));
+        }
+
         $thumbDirName = '/' . ($keepRatio ? 'scaled-' : 'thumbs-') . $width . '-' . $height . '/';
         $imagePath = $this->getPath($image);
         $thumbFilePath = dirname($imagePath) . $thumbDirName . basename($imagePath);
index 65717b86b00f0156b64c607bf293740ac1d62014..0e40b20ca17685250a2b486690d2a5e9c70b58d2 100644 (file)
@@ -37,14 +37,14 @@ function mounted() {
 
             dz.on('error', function (file, errorMessage, xhr) {
                 _this.$emit('error', {file, errorMessage, xhr});
-                console.log(errorMessage);
-                console.log(xhr);
+
                 function setMessage(message) {
                     $(file.previewElement).find('[data-dz-errormessage]').text(message);
                 }
 
                 if (xhr && xhr.status === 413) setMessage(trans('errors.server_upload_limit'));
-                if (errorMessage.file) setMessage(errorMessage.file[0]);
+                else if (errorMessage.file) setMessage(errorMessage.file);
+
             });
         }
    });