diff --git a/inc/functions/metadata.php b/inc/functions/metadata.php index 9abfecb7..e0a267c2 100644 --- a/inc/functions/metadata.php +++ b/inc/functions/metadata.php @@ -14,6 +14,14 @@ const SUPPORTED_IMAGE_MIME_TYPES = [ 'image/avif' ]; +/** + * Non-image file types for which only thumbnail generation is supported. + */ +const SUPPORTED_THUMB_MIME_TYPES = [ + 'text/plain', + 'application/pdf' +]; + /** * @param string $mime Lowercase valid mime type. * @return ?string Vichan's preferred extension for the given mime type, if any. @@ -25,7 +33,9 @@ function mime_to_ext(string $mime): ?string { 'image/gif' => 'gif', 'image/webp' => 'webp', 'image/bmp' => 'bmp', - 'image/avif' => 'avif' + 'image/avif' => 'avif', + 'text/plain' => 'txt', + 'application/pdf' => 'pdf' ]; return $mime_to_ext[$mime] ?? null; } @@ -43,6 +53,8 @@ function ext_to_mime(string $ext): ?string { 'webp' => 'image/webp', 'bmp' => 'image/bmp', 'avif' => 'image/avif', + 'txt' => 'text/plain', + 'pdf' => 'application/pdf' ]; return $ext_to_mime[$ext] ?? null; }