Browse Source

Fix client supported image formats (#9071)

Teo Baranga 2 years ago
parent
commit
56ef45ebf0
1 changed files with 3 additions and 10 deletions
  1. 3 10
      Jellyfin.Api/Controllers/ImageController.cs

+ 3 - 10
Jellyfin.Api/Controllers/ImageController.cs

@@ -28,7 +28,6 @@ using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Logging;
 using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Primitives;
 using Microsoft.Net.Http.Headers;
 using Microsoft.Net.Http.Headers;
 
 
 namespace Jellyfin.Api.Controllers
 namespace Jellyfin.Api.Controllers
@@ -2038,13 +2037,8 @@ namespace Jellyfin.Api.Controllers
             }
             }
 
 
             var acceptParam = Request.Query[HeaderNames.Accept];
             var acceptParam = Request.Query[HeaderNames.Accept];
-            if (StringValues.IsNullOrEmpty(acceptParam))
-            {
-                return Array.Empty<ImageFormat>();
-            }
 
 
-            // Can't be null, checked above
-            var supportsWebP = SupportsFormat(supportedFormats, acceptParam!, ImageFormat.Webp, false);
+            var supportsWebP = SupportsFormat(supportedFormats, acceptParam, ImageFormat.Webp, false);
 
 
             if (!supportsWebP)
             if (!supportsWebP)
             {
             {
@@ -2066,8 +2060,7 @@ namespace Jellyfin.Api.Controllers
             formats.Add(ImageFormat.Jpg);
             formats.Add(ImageFormat.Jpg);
             formats.Add(ImageFormat.Png);
             formats.Add(ImageFormat.Png);
 
 
-            // Can't be null, checked above
-            if (SupportsFormat(supportedFormats, acceptParam!, ImageFormat.Gif, true))
+            if (SupportsFormat(supportedFormats, acceptParam, ImageFormat.Gif, true))
             {
             {
                 formats.Add(ImageFormat.Gif);
                 formats.Add(ImageFormat.Gif);
             }
             }
@@ -2075,7 +2068,7 @@ namespace Jellyfin.Api.Controllers
             return formats.ToArray();
             return formats.ToArray();
         }
         }
 
 
-        private bool SupportsFormat(IReadOnlyCollection<string> requestAcceptTypes, string acceptParam, ImageFormat format, bool acceptAll)
+        private bool SupportsFormat(IReadOnlyCollection<string> requestAcceptTypes, string? acceptParam, ImageFormat format, bool acceptAll)
         {
         {
             if (requestAcceptTypes.Contains(format.GetMimeType()))
             if (requestAcceptTypes.Contains(format.GetMimeType()))
             {
             {