mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-19 12:44:19 +01:00
Cleanup PreferEpisodeParentPoster)
This commit is contained in:
@@ -1385,7 +1385,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
}
|
||||
}
|
||||
|
||||
if (options.PreferEpisodeParentPoster)
|
||||
if (options.GetImageLimit(ImageType.Primary) > 0)
|
||||
{
|
||||
var episodeSeason = episode.Season;
|
||||
var seasonPrimaryTag = episodeSeason is not null
|
||||
|
||||
@@ -551,8 +551,6 @@ public class UserLibraryController : BaseJellyfinApiController
|
||||
var dtoOptions = new DtoOptions { Fields = fields }
|
||||
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
||||
|
||||
dtoOptions.PreferEpisodeParentPoster = true;
|
||||
|
||||
var list = _userViewManager.GetLatestItems(
|
||||
new LatestItemsQuery
|
||||
{
|
||||
|
||||
@@ -81,13 +81,6 @@ namespace MediaBrowser.Controller.Dto
|
||||
/// </summary>
|
||||
public bool AddCurrentProgram { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether an episode's portrait poster (its season's primary
|
||||
/// image, falling back to the series') should replace the episode's own (16:9) primary image.
|
||||
/// Used by views that render episodes as poster cards, e.g. "Latest".
|
||||
/// </summary>
|
||||
public bool PreferEpisodeParentPoster { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the specified field is populated.
|
||||
/// </summary>
|
||||
|
||||
@@ -57,14 +57,10 @@ public class DtoServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBaseItemDto_PreferEpisodeParentPoster_AttachesSeasonPosterWithoutDroppingEpisodeImage()
|
||||
public void GetBaseItemDto_Episode_AttachesSeasonPosterAsParentPrimaryImage()
|
||||
{
|
||||
var (episode, season, _) = BuildEpisode(seasonHasPoster: true);
|
||||
var options = new DtoOptions(false)
|
||||
{
|
||||
PreferEpisodeParentPoster = true,
|
||||
Fields = [ItemFields.PrimaryImageAspectRatio]
|
||||
};
|
||||
var options = new DtoOptions(false) { Fields = [ItemFields.PrimaryImageAspectRatio] };
|
||||
|
||||
var dto = _dtoService.GetBaseItemDto(episode, options);
|
||||
|
||||
@@ -80,10 +76,10 @@ public class DtoServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBaseItemDto_PreferEpisodeParentPoster_FallsBackToSeriesWhenSeasonHasNoPoster()
|
||||
public void GetBaseItemDto_Episode_ParentPrimaryImageFallsBackToSeriesWhenSeasonHasNoPoster()
|
||||
{
|
||||
var (episode, _, series) = BuildEpisode(seasonHasPoster: false);
|
||||
var options = new DtoOptions(false) { PreferEpisodeParentPoster = true };
|
||||
var options = new DtoOptions(false);
|
||||
|
||||
var dto = _dtoService.GetBaseItemDto(episode, options);
|
||||
|
||||
@@ -96,26 +92,28 @@ public class DtoServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBaseItemDto_WithoutPreferEpisodeParentPoster_KeepsEpisodePrimary()
|
||||
public void GetBaseItemDto_Episode_WithoutParentPosters_KeepsOnlyEpisodePrimary()
|
||||
{
|
||||
var (episode, _, _) = BuildEpisode(seasonHasPoster: true);
|
||||
var (episode, _, _) = BuildEpisode(seasonHasPoster: false, seriesHasPoster: false);
|
||||
var options = new DtoOptions(false);
|
||||
|
||||
var dto = _dtoService.GetBaseItemDto(episode, options);
|
||||
|
||||
// Default behavior: the episode keeps its own primary and exposes the series poster as a tag.
|
||||
// With no season or series poster there is nothing to attach; the episode keeps its own primary.
|
||||
Assert.NotNull(dto.ImageTags);
|
||||
Assert.True(dto.ImageTags.ContainsKey(ImageType.Primary));
|
||||
Assert.NotNull(dto.SeriesPrimaryImageTag);
|
||||
Assert.Null(dto.ParentPrimaryImageItemId);
|
||||
}
|
||||
|
||||
private (Episode Episode, Season Season, Series Series) BuildEpisode(bool seasonHasPoster)
|
||||
private (Episode Episode, Season Season, Series Series) BuildEpisode(bool seasonHasPoster, bool seriesHasPoster = true)
|
||||
{
|
||||
// Non-local (http) paths keep aspect-ratio resolution off the image processor and on the
|
||||
// item's default ratio, which is portrait (2/3) for Season/Series and 16:9 for Episode.
|
||||
var series = new Series { Id = Guid.NewGuid(), Name = "Series" };
|
||||
series.SetImage(new ItemImageInfo { Type = ImageType.Primary, Path = "http://test/series.jpg" }, 0);
|
||||
if (seriesHasPoster)
|
||||
{
|
||||
series.SetImage(new ItemImageInfo { Type = ImageType.Primary, Path = "http://test/series.jpg" }, 0);
|
||||
}
|
||||
|
||||
var season = new Season { Id = Guid.NewGuid(), Name = "Season", SeriesId = series.Id };
|
||||
if (seasonHasPoster)
|
||||
|
||||
Reference in New Issue
Block a user