diff --git a/app/Config/Publisher.php b/app/Config/Publisher.php index bf03be1db7e0..0cb6769972fc 100644 --- a/app/Config/Publisher.php +++ b/app/Config/Publisher.php @@ -23,6 +23,6 @@ class Publisher extends BasePublisher */ public $restrictions = [ ROOTPATH => '*', - FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i', + FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|avif|bmp|ico|svg)$#i', ]; } diff --git a/system/Database/BaseResult.php b/system/Database/BaseResult.php index 8a624029b3a2..8720b5fe111c 100644 --- a/system/Database/BaseResult.php +++ b/system/Database/BaseResult.php @@ -260,8 +260,8 @@ public function getResultObject(): array * @param string $type The type of result object. 'array', 'object' or class name. * @phpstan-param class-string|'array'|'object' $type * - * @return array|object|stdClass|null - * @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null)) + * @return array|float|int|object|stdClass|string|null + * @phpstan-return ($n is string ? float|int|string|null : ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))) */ public function getRow($n = 0, string $type = 'object') { diff --git a/system/Database/ResultInterface.php b/system/Database/ResultInterface.php index ea5f0de2800f..2b1deb98c6b6 100644 --- a/system/Database/ResultInterface.php +++ b/system/Database/ResultInterface.php @@ -63,8 +63,8 @@ public function getResultObject(): array; * @param string $type The type of result object. 'array', 'object' or class name. * @phpstan-param class-string|'array'|'object' $type * - * @return array|object|stdClass|null - * @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null)) + * @return array|float|int|object|stdClass|string|null + * @phpstan-return ($n is string ? float|int|string|null : ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))) */ public function getRow($n = 0, string $type = 'object'); diff --git a/system/Images/Handlers/BaseHandler.php b/system/Images/Handlers/BaseHandler.php index 92644eede3db..14377bd1eb7c 100644 --- a/system/Images/Handlers/BaseHandler.php +++ b/system/Images/Handlers/BaseHandler.php @@ -113,6 +113,7 @@ abstract class BaseHandler implements ImageHandlerInterface protected $supportTransparency = [ IMAGETYPE_PNG, IMAGETYPE_WEBP, + IMAGETYPE_AVIF, ]; /** diff --git a/system/Images/Handlers/GDHandler.php b/system/Images/Handlers/GDHandler.php index f2cd55874044..8d8422b6eef0 100644 --- a/system/Images/Handlers/GDHandler.php +++ b/system/Images/Handlers/GDHandler.php @@ -275,6 +275,16 @@ public function save(?string $target = null, int $quality = 90): bool } break; + case IMAGETYPE_AVIF: + if (! function_exists('imageavif')) { + throw ImageException::forInvalidImageCreate(lang('Images.avifNotSupported')); + } + + if (! @imagewebp($this->resource, $target, $quality)) { + throw ImageException::forSaveFailed(); + } + break; + default: throw ImageException::forInvalidImageCreate(); } @@ -365,6 +375,13 @@ protected function getImageResource(string $path, int $imageType) } return imagecreatefromwebp($path); + + case IMAGETYPE_AVIF: + if (! function_exists('imagecreatefromavif')) { + throw ImageException::forInvalidImageCreate(lang('Images.avifNotSupported')); + } + + return imagecreatefromavif($path); default: throw ImageException::forInvalidImageCreate('Ima'); diff --git a/system/Images/Image.php b/system/Images/Image.php index 291ad002a6f2..da0ce94097d2 100644 --- a/system/Images/Image.php +++ b/system/Images/Image.php @@ -110,6 +110,7 @@ public function getProperties(bool $return = false) IMAGETYPE_JPEG => 'jpeg', IMAGETYPE_PNG => 'png', IMAGETYPE_WEBP => 'webp', + IMAGETYPE_AVIF => 'avif', ]; $mime = 'image/' . ($types[$vals[2]] ?? 'jpg'); diff --git a/system/Language/en/Images.php b/system/Language/en/Images.php index be4d52903ce4..1949bd093fb6 100644 --- a/system/Language/en/Images.php +++ b/system/Language/en/Images.php @@ -18,6 +18,7 @@ 'jpgNotSupported' => 'JPG images are not supported.', 'pngNotSupported' => 'PNG images are not supported.', 'webpNotSupported' => 'WEBP images are not supported.', + 'avifNotSupported' => 'AVIF images are not supported.', 'fileNotSupported' => 'The supplied file is not a supported image type.', 'unsupportedImageCreate' => 'Your server does not support the GD function required to process this type of image.', 'jpgOrPngRequired' => 'The image resize protocol specified in your preferences only works with JPEG or PNG image types.',