From 371796cce94a4858ae1eedde9a2547b2addd6304 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Tue, 7 Sep 2021 11:04:05 +0000 Subject: [PATCH] Support additional image formats: - APNG - AVIF - GIF - SVG --- src/library/types.cr | 10 +++++++++- src/util/util.cr | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/library/types.cr b/src/library/types.cr index a4de007..0545184 100644 --- a/src/library/types.cr +++ b/src/library/types.cr @@ -1,4 +1,12 @@ -SUPPORTED_IMG_TYPES = ["image/jpeg", "image/png", "image/webp"] +SUPPORTED_IMG_TYPES = %w( + image/jpeg + image/png + image/webp + image/apng + image/avif + image/gif + image/svg+xml +) enum SortMethod Auto diff --git a/src/util/util.cr b/src/util/util.cr index c4e168a..bc710bd 100644 --- a/src/util/util.cr +++ b/src/util/util.cr @@ -35,6 +35,11 @@ def register_mime_types # FontAwesome fonts ".woff" => "font/woff", ".woff2" => "font/woff2", + + # Supported image formats. JPG, PNG, GIF, WebP, and SVG are already + # defiend by Crystal in `MIME.DEFAULT_TYPES` + ".apng" => "image/apng", + ".avif" => "image/avif", }.each do |k, v| MIME.register k, v end