Fix GetImage endpoint to proxy images instead of redirecting

This commit is contained in:
2026-02-03 19:02:42 -05:00
parent 9f8b3d65fb
commit f7a88791e8

View File

@@ -940,24 +940,19 @@ public class JellyfinController : ControllerBase
if (!isExternal) if (!isExternal)
{ {
// Redirect to Jellyfin directly for local content images // Proxy image from Jellyfin for local content
var queryString = new List<string>(); var (imageBytes, contentType) = await _proxyService.GetImageAsync(
if (maxWidth.HasValue) queryString.Add($"maxWidth={maxWidth.Value}"); itemId,
if (maxHeight.HasValue) queryString.Add($"maxHeight={maxHeight.Value}"); imageType,
maxWidth,
maxHeight);
var path = $"Items/{itemId}/Images/{imageType}"; if (imageBytes == null || contentType == null)
if (imageIndex > 0)
{ {
path = $"Items/{itemId}/Images/{imageType}/{imageIndex}"; return NotFound();
} }
if (queryString.Any()) return File(imageBytes, contentType);
{
path = $"{path}?{string.Join("&", queryString)}";
}
var jellyfinUrl = $"{_settings.Url?.TrimEnd('/')}/{path}";
return Redirect(jellyfinUrl);
} }
// Get external cover art URL // Get external cover art URL