diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
index 98c1a093a4408475525c63a3afb1724a6be03e05..2ce434e0fd3d896b77538984dfe5041ba98a67f1 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
@@ -562,7 +562,7 @@ protected static function checkAvifSupport(): bool {
     }
 
     $tempFile = fopen('php://memory', 'r+');
-    $supported = imageavif(imagecreatetruecolor(1, 1), $tempFile, 0, 10) && fstat($tempFile)['size'] > 0;
+    $supported = function_exists('imageavif') && imageavif(imagecreatetruecolor(1, 1), $tempFile, 0, 10) && fstat($tempFile)['size'] > 0;
     fclose($tempFile);
 
     return $supported;