Skip thumbnails for non-image files
authorAlexander Ebert <ebert@woltlab.com>
Mon, 15 Apr 2024 10:18:16 +0000 (12:18 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 8 Jun 2024 10:19:38 +0000 (12:19 +0200)
wcfsetup/install/files/lib/data/file/thumbnail/FileThumbnailEditor.class.php
wcfsetup/install/files/lib/system/file/processor/FileProcessor.class.php

index 05118c1b63303bfb76465ee5669af8847db66b21..2f34c47bc2d7c86c103f5db0553bb89538da5a0b 100644 (file)
@@ -35,7 +35,7 @@ class FileThumbnailEditor extends DatabaseObjectEditor
             'data' => [
                 'fileID' => $file->fileID,
                 'identifier' => $format->identifier,
-                'fileHash' => hash_file('sha256', $filename),
+                'fileHash' => \hash_file('sha256', $filename),
                 'fileExtension' => 'webp',
                 'width' => $width,
                 'height' => $height,
index f0ab87ecfe9dc4bc6ff21b76223bef9393f91921..fe6639b445770d5b58067c0c1eb0daf2987a5d14 100644 (file)
@@ -72,6 +72,10 @@ final class FileProcessor extends SingletonFactory
 
     public function generateThumbnails(File $file): void
     {
+        if (!$file->isImage()) {
+            return;
+        }
+
         $processor = $file->getProcessor();
         if ($processor === null) {
             return;