diff --git a/composer.json b/composer.json
index c5d525d..ebe02bb 100644
--- a/composer.json
+++ b/composer.json
@@ -17,8 +17,8 @@
   "license": "GPL-2.0-or-later",
   "minimum-stability": "dev",
   "require": {
-    "drupal/core": "^10 || ^11",
-    "drupal/imagemagick": "^3.7 || ^4.0"
+    "drupal/imagemagick": "^3.7 || ^4.0",
+    "drupal/core": "^10.1 || ^11 || ^12"
   },
   "require-dev": {
     "drupal/imagemagick": "^4.0"
diff --git a/pdfpreview.info.yml b/pdfpreview.info.yml
index 2fdecdf..734dfcd 100644
--- a/pdfpreview.info.yml
+++ b/pdfpreview.info.yml
@@ -2,7 +2,7 @@ name: PDF Preview
 type: module
 description: Show a snapshot of the first page of pdf files attached to nodes.
 package: Media
-core_version_requirement: ^10 || ^11
+core_version_requirement: ^10.1 || ^11 || ^12
 configure: pdfpreview.settings
 dependencies:
   - drupal:image
diff --git a/pdfpreview.module b/pdfpreview.module
index f08c96b..479d426 100644
--- a/pdfpreview.module
+++ b/pdfpreview.module
@@ -7,31 +7,32 @@
 
 declare(strict_types=1);
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\pdfpreview\Hook\PdfpreviewHooks;
 use Drupal\file\FileInterface;
 
 /**
  * Implements hook_theme().
  */
+#[LegacyHook]
 function pdfpreview_theme(): array {
-  return [
-    'pdfpreview_formatter' => [
-      'render element' => 'element',
-    ],
-  ];
+  return \Drupal::service(PdfpreviewHooks::class)->theme();
 }
 
 /**
  * Implements hook_ENTITY_TYPE_update().
  */
+#[LegacyHook]
 function pdfpreview_file_update(FileInterface $file): void {
-  \Drupal::service('pdfpreview.generator')->updatePdfPreview($file);
+  \Drupal::service(PdfpreviewHooks::class)->fileUpdate($file);
 }
 
 /**
  * Implements hook_ENTITY_TYPE_delete().
  */
+#[LegacyHook]
 function pdfpreview_file_delete(FileInterface $file): void {
-  \Drupal::service('pdfpreview.generator')->deletePdfPreview($file);
+  \Drupal::service(PdfpreviewHooks::class)->fileDelete($file);
 }
 
 /**
diff --git a/pdfpreview.services.yml b/pdfpreview.services.yml
index dd533f7..e421d32 100644
--- a/pdfpreview.services.yml
+++ b/pdfpreview.services.yml
@@ -2,3 +2,7 @@ services:
   pdfpreview.generator:
     class: Drupal\pdfpreview\PdfPreviewGenerator
     arguments: ['@config.factory', '@file_system', '@transliteration', '@image.toolkit.manager', '@language_manager']
+
+  Drupal\pdfpreview\Hook\PdfpreviewHooks:
+    class: Drupal\pdfpreview\Hook\PdfpreviewHooks
+    autowire: true
diff --git a/src/Hook/PdfpreviewHooks.php b/src/Hook/PdfpreviewHooks.php
new file mode 100644
index 0000000..33acdc3
--- /dev/null
+++ b/src/Hook/PdfpreviewHooks.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Drupal\pdfpreview\Hook;
+
+use Drupal\file\FileInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+
+/**
+ * Hook implementations for pdfpreview.
+ */
+class PdfpreviewHooks {
+
+  /**
+   * Implements hook_theme().
+   */
+  #[Hook('theme')]
+  public static function theme(): array {
+    return [
+      'pdfpreview_formatter' => [
+        'render element' => 'element',
+      ],
+    ];
+  }
+
+  /**
+   * Implements hook_ENTITY_TYPE_update().
+   */
+  #[Hook('file_update')]
+  public static function fileUpdate(FileInterface $file): void {
+    \Drupal::service('pdfpreview.generator')->updatePdfPreview($file);
+  }
+
+  /**
+   * Implements hook_ENTITY_TYPE_delete().
+   */
+  #[Hook('file_delete')]
+  public static function fileDelete(FileInterface $file): void {
+    \Drupal::service('pdfpreview.generator')->deletePdfPreview($file);
+  }
+
+}
diff --git a/src/PdfPreviewGenerator.php b/src/PdfPreviewGenerator.php
index 504cd70..d829aef 100644
--- a/src/PdfPreviewGenerator.php
+++ b/src/PdfPreviewGenerator.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
 
 namespace Drupal\pdfpreview;
 
+use Drupal\Component\Utility\DeprecationHelper;
 use Drupal\Component\Transliteration\TransliterationInterface;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\File\FileSystemInterface;
@@ -60,7 +61,7 @@ class PdfPreviewGenerator {
     $uri = $this->getDestinationUri($file);
     if (file_exists($uri)) {
       $this->fileSystem->delete($uri);
-      image_path_flush($uri);
+      DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.4.0', fn() => \Drupal::service('Drupal\image\ImageDerivativeUtilities')->pathFlush($uri), fn() => image_path_flush($uri));
     }
   }
 
@@ -69,7 +70,7 @@ class PdfPreviewGenerator {
    */
   public function updatePdfPreview(FileInterface $file): void {
     /** @var \Drupal\file\FileInterface $original */
-    $original = $file->original ?? $file;
+    $original = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.2.0', fn() => $file->getOriginal(), fn() => $file->original) ?? $file;
     if ($file->getFileUri() !== $original->getFileUri()
       || filesize($file->getFileUri()) !== filesize($original->getFileUri())) {
       $this->deletePdfPreview($original);
@@ -121,7 +122,7 @@ class PdfPreviewGenerator {
     $output_path = $scheme . '://' . $config->get('path');
 
     if ($config->get('filenames') == 'human') {
-      $filename = $this->fileSystem->basename($file->getFileUri(), '.pdf');
+      $filename = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.3.0', fn() => basename($file->getFileUri(), '.pdf'), fn() => $this->fileSystem->basename($file->getFileUri(), '.pdf'));
       $filename = $this->transliteration->transliterate($filename, $langcode);
       $filename = $file->id() . '-' . $filename;
     }
diff --git a/src/Plugin/Field/FieldFormatter/PdfPreviewFormatter.php b/src/Plugin/Field/FieldFormatter/PdfPreviewFormatter.php
index 847476a..81c3bbb 100644
--- a/src/Plugin/Field/FieldFormatter/PdfPreviewFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/PdfPreviewFormatter.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
 
 namespace Drupal\pdfpreview\Plugin\Field\FieldFormatter;
 
+use Drupal\Component\Utility\DeprecationHelper;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Field\FieldItemListInterface;
@@ -113,7 +114,7 @@ class PdfPreviewFormatter extends ImageFormatter {
       '#type' => 'checkbox',
       '#title' => $this->t('Fallback to default file formatter'),
       '#description' => $this->t('When enabled, non-PDF files will be formatted using a default file formatter.'),
-      '#default_value' => (boolean) $this->getSetting('fallback_formatter'),
+      '#default_value' => (bool) $this->getSetting('fallback_formatter'),
       '#return_value' => $this->configFactory->get('pdfpreview.settings')->get('fallback_formatter'),
     ];
     return $form;
@@ -209,7 +210,17 @@ class PdfPreviewFormatter extends ImageFormatter {
           $item->uri = $preview_uri;
           $item->width = $preview->getWidth();
           $item->height = $preview->getHeight();
-          $elements[$delta] = [
+          $elements[$delta] = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.4.0', fn() => [
+            '#theme' => 'image_formatter',
+            '#item' => $item,
+            '#attributes' => $item_attributes,
+            '#image_style' => $image_style_setting,
+            '#url' => $url,
+            '#cache' => [
+              'tags' => $cache_tags,
+              'contexts' => $cache_contexts,
+            ],
+          ], fn() => [
             '#theme' => 'image_formatter',
             '#item' => $item,
             '#item_attributes' => $item_attributes,
@@ -219,7 +230,7 @@ class PdfPreviewFormatter extends ImageFormatter {
               'tags' => $cache_tags,
               'contexts' => $cache_contexts,
             ],
-          ];
+          ]);
         }
       }
       if (!$show_preview) {
diff --git a/tests/src/Kernel/PdfPreviewGeneratorTest.php b/tests/src/Kernel/PdfPreviewGeneratorTest.php
index 76e2618..da7cfce 100644
--- a/tests/src/Kernel/PdfPreviewGeneratorTest.php
+++ b/tests/src/Kernel/PdfPreviewGeneratorTest.php
@@ -4,6 +4,8 @@ declare(strict_types=1);
 
 namespace Drupal\Tests\pdfpreview\Kernel;
 
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
 use Drupal\Core\Logger\RfcLoggerTrait;
 use Drupal\Core\Logger\RfcLogLevel;
 use Drupal\Core\Site\Settings;
@@ -19,6 +21,8 @@ use Psr\Log\LoggerInterface;
  * @coversDefaultClass \Drupal\pdfpreview\PdfPreviewGenerator
  * @group pdfpreview
  */
+#[Group('pdfpreview')]
+#[RunTestsInSeparateProcesses]
 final class PdfPreviewGeneratorTest extends KernelTestBase implements LoggerInterface {
 
   use RfcLoggerTrait;
diff --git a/tests/src/Unit/PdfPreviewGeneratorTest.php b/tests/src/Unit/PdfPreviewGeneratorTest.php
index b71c56a..1815b19 100644
--- a/tests/src/Unit/PdfPreviewGeneratorTest.php
+++ b/tests/src/Unit/PdfPreviewGeneratorTest.php
@@ -4,6 +4,8 @@ declare(strict_types=1);
 
 namespace Drupal\Tests\pdfpreview\Unit;
 
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\DataProvider;
 use Drupal\Component\Transliteration\TransliterationInterface;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Config\ImmutableConfig;
@@ -16,16 +18,17 @@ use Drupal\Tests\UnitTestCase;
  *
  * @group pdfpreview
  */
+#[Group('pdfpreview')]
 class PdfPreviewGeneratorTest extends UnitTestCase {
 
   /**
    * @covers ::getDestinationUri
    * @dataProvider destinationUriProvider
    */
+  #[DataProvider('destinationUriProvider')]
   public function testGetDestinationUri(string $filenames, string $type, string $expected): void {
     $reflection = new \ReflectionClass(PdfPreviewGenerator::class);
     $method = $reflection->getMethod('getDestinationUri');
-    $method->setAccessible(TRUE);
 
     $config = $this->createMock(ImmutableConfig::class);
     $config
@@ -58,7 +61,7 @@ class PdfPreviewGeneratorTest extends UnitTestCase {
   /**
    * Data provider for testGetDestinationUri.
    */
-  public function destinationUriProvider(): array {
+  public static function destinationUriProvider(): array {
     return [
       ['md5', 'jpg', 'public://pdfpreview/117aa294817277a5c090bf18d515d885.jpg'],
       ['md5', 'png', 'public://pdfpreview/117aa294817277a5c090bf18d515d885.png'],
