diff --git a/src/Services/Misc/FAIconGenerator.php b/src/Services/Misc/FAIconGenerator.php index 997e9f39..18db1fad 100644 --- a/src/Services/Misc/FAIconGenerator.php +++ b/src/Services/Misc/FAIconGenerator.php @@ -56,9 +56,6 @@ class FAIconGenerator */ public function fileExtensionToFAType(string $extension): string { - if ('' === $extension) { - throw new InvalidArgumentException('You must specify an extension!'); - } //Normalize file extension $extension = strtolower($extension); foreach (self::EXT_MAPPING as $fa => $exts) { diff --git a/src/Twig/AttachmentExtension.php b/src/Twig/AttachmentExtension.php index fd93de9a..9f81abe6 100644 --- a/src/Twig/AttachmentExtension.php +++ b/src/Twig/AttachmentExtension.php @@ -39,8 +39,8 @@ final class AttachmentExtension extends AbstractExtension return [ /* Returns the URL to a thumbnail of the given attachment */ new TwigFunction('attachment_thumbnail', fn(Attachment $attachment, string $filter_name = 'thumbnail_sm'): ?string => $this->attachmentURLGenerator->getThumbnailURL($attachment, $filter_name)), - /* Returns the font awesome icon class which is representing the given file extension */ - new TwigFunction('ext_to_fa_icon', fn(string $extension): string => $this->FAIconGenerator->fileExtensionToFAType($extension)), + /* Returns the font awesome icon class which is representing the given file extension (We allow null here for attachments without extension) */ + new TwigFunction('ext_to_fa_icon', fn(?string $extension): string => $this->FAIconGenerator->fileExtensionToFAType($extension ?? '')), ]; } }