]> source.dussan.org Git - nextcloud-server.git/commitdiff
feat(preview): move previews for imaginary pdf to own class ImaginaryPDF 46508/head
authorernolf <raphael.gradenwitz@googlemail.com>
Sat, 13 Jul 2024 10:59:22 +0000 (12:59 +0200)
committerDaniel Kesselberg <mail@danielkesselberg.de>
Thu, 25 Jul 2024 15:01:01 +0000 (17:01 +0200)
Signed-off-by: ernolf <raphael.gradenwitz@googlemail.com>
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
config/config.sample.php
lib/composer/composer/autoload_classmap.php
lib/composer/composer/autoload_static.php
lib/private/Preview/Imaginary.php
lib/private/Preview/ImaginaryPDF.php [new file with mode: 0644]
lib/private/PreviewManager.php

index 9840fcfc97caa6e7f45614947ce7da9ee02e1ffa..ba0ea6d4101368df288a9988db278ec3cd1344f6 100644 (file)
@@ -1296,7 +1296,13 @@ $CONFIG = [
 
 /**
  * Set the URL of the Imaginary service to send image previews to.
- * Also requires the ``OC\Preview\Imaginary`` provider to be enabled.
+ * Also requires the
+ *  - ``OC\Preview\Imaginary``
+ * provider to be enabled in the 'enabledPreviewProviders' array, to create previews for these mimetypes:
+ * bmp, x-bitmap, png, jpeg, gif, heic, heif, svg+xml, tiff, webp and illustrator.
+ * If you want Imaginary to also create preview images from PDF Documents, you have to add
+ *  - ``OC\Preview\ImaginaryPDF``
+ * provider as well.
  *
  * See https://github.com/h2non/imaginary
  */
index e359a089fe13605d47766aa3b5da02e02efee83e..dc0c8f0e6c6ec8aef2df910b6f62084db2467ec8 100644 (file)
@@ -1689,6 +1689,7 @@ return array(
     'OC\\Preview\\Illustrator' => $baseDir . '/lib/private/Preview/Illustrator.php',
     'OC\\Preview\\Image' => $baseDir . '/lib/private/Preview/Image.php',
     'OC\\Preview\\Imaginary' => $baseDir . '/lib/private/Preview/Imaginary.php',
+    'OC\\Preview\\ImaginaryPDF' => $baseDir . '/lib/private/Preview/ImaginaryPDF.php',
     'OC\\Preview\\JPEG' => $baseDir . '/lib/private/Preview/JPEG.php',
     'OC\\Preview\\Krita' => $baseDir . '/lib/private/Preview/Krita.php',
     'OC\\Preview\\MP3' => $baseDir . '/lib/private/Preview/MP3.php',
index de92b293fcb4b99bed68ad4f4ee0927ac10a396e..635854db4c6e46c98f607f843d4a928ba473060f 100644 (file)
@@ -1722,6 +1722,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
         'OC\\Preview\\Illustrator' => __DIR__ . '/../../..' . '/lib/private/Preview/Illustrator.php',
         'OC\\Preview\\Image' => __DIR__ . '/../../..' . '/lib/private/Preview/Image.php',
         'OC\\Preview\\Imaginary' => __DIR__ . '/../../..' . '/lib/private/Preview/Imaginary.php',
+        'OC\\Preview\\ImaginaryPDF' => __DIR__ . '/../../..' . '/lib/private/Preview/ImaginaryPDF.php',
         'OC\\Preview\\JPEG' => __DIR__ . '/../../..' . '/lib/private/Preview/JPEG.php',
         'OC\\Preview\\Krita' => __DIR__ . '/../../..' . '/lib/private/Preview/Krita.php',
         'OC\\Preview\\MP3' => __DIR__ . '/../../..' . '/lib/private/Preview/MP3.php',
index 23459be3b51995637ab409b89903972875901259..baa883f4bd9f62dc5da67cb7ed4bd831febf7972 100644 (file)
@@ -40,7 +40,7 @@ class Imaginary extends ProviderV2 {
        }
 
        public static function supportedMimeTypes(): string {
-               return '/(image\/(bmp|x-bitmap|png|jpeg|gif|heic|heif|svg\+xml|tiff|webp)|application\/(pdf|illustrator))/';
+               return '/(image\/(bmp|x-bitmap|png|jpeg|gif|heic|heif|svg\+xml|tiff|webp)|application\/illustrator)/';
        }
 
        public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop): ?IImage {
diff --git a/lib/private/Preview/ImaginaryPDF.php b/lib/private/Preview/ImaginaryPDF.php
new file mode 100644 (file)
index 0000000..d26c6d1
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OC\Preview;
+
+class ImaginaryPDF extends Imaginary {
+       public static function supportedMimeTypes(): string {
+               return '/application\/pdf/';
+       }
+}
index 4daf5b2dc1efd34ad1bffc4650a5de0df25f1cfd..f19ff25abb786b807d2884e9025d6932fa56508f 100644 (file)
@@ -346,6 +346,7 @@ class PreviewManager implements IPreview {
                $this->registerCoreProvider(Preview\MP3::class, '/audio\/mpeg/');
                $this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/');
                $this->registerCoreProvider(Preview\Imaginary::class, Preview\Imaginary::supportedMimeTypes());
+               $this->registerCoreProvider(Preview\ImaginaryPDF::class, Preview\ImaginaryPDF::supportedMimeTypes());
 
                // SVG and Bitmap require imagick
                if ($this->imagickSupport->hasExtension()) {