forked from leftypol/leftypol
metadata.php: add SUPPORTED_THUMB_MIME_TYPES with pdf and txt
This commit is contained in:
parent
9d92517980
commit
f029dba382
1 changed files with 13 additions and 1 deletions
|
@ -14,6 +14,14 @@ const SUPPORTED_IMAGE_MIME_TYPES = [
|
||||||
'image/avif'
|
'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.
|
* @param string $mime Lowercase valid mime type.
|
||||||
* @return ?string Vichan's preferred extension for the given mime type, if any.
|
* @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/gif' => 'gif',
|
||||||
'image/webp' => 'webp',
|
'image/webp' => 'webp',
|
||||||
'image/bmp' => 'bmp',
|
'image/bmp' => 'bmp',
|
||||||
'image/avif' => 'avif'
|
'image/avif' => 'avif',
|
||||||
|
'text/plain' => 'txt',
|
||||||
|
'application/pdf' => 'pdf'
|
||||||
];
|
];
|
||||||
return $mime_to_ext[$mime] ?? null;
|
return $mime_to_ext[$mime] ?? null;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +53,8 @@ function ext_to_mime(string $ext): ?string {
|
||||||
'webp' => 'image/webp',
|
'webp' => 'image/webp',
|
||||||
'bmp' => 'image/bmp',
|
'bmp' => 'image/bmp',
|
||||||
'avif' => 'image/avif',
|
'avif' => 'image/avif',
|
||||||
|
'txt' => 'text/plain',
|
||||||
|
'pdf' => 'application/pdf'
|
||||||
];
|
];
|
||||||
return $ext_to_mime[$ext] ?? null;
|
return $ext_to_mime[$ext] ?? null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue