mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-08-11 09:13:54 -04:00
Fix client supported image formats (#9071)
This commit is contained in:
parent
663854bc1e
commit
56ef45ebf0
@ -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()))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user