Skip to content

Commit

Permalink
fix: set all fields when converting the current TMDB image to `IImage…
Browse files Browse the repository at this point in the history
…Metadata`

Set all the fields on a cloned object when we convert the TMDB image to an `IImageMetadata` object if the `preferred` value difference from the image's `IsPreferred`, otherwise just return the original image. This will ensure we're sending the correct metadata for the preferred image when it's a TMDB image.
  • Loading branch information
revam committed Jan 14, 2025
1 parent fb9c86a commit a95c83a
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions Shoko.Server/Models/TMDB/TMDB_Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,30 @@ private bool Populate(ImageData data)
};

public IImageMetadata GetImageMetadata(bool preferred = false)
=> new Image_Base(DataSourceEnum.TMDB, ImageType, ID, LocalPath, RemoteURL)
{
IsEnabled = IsEnabled,
IsPreferred = preferred,
_width = Width,
_height = Height,
};
=> preferred == IsPreferred
? this
: new TMDB_Image(RemoteFileName, ImageType)
{
IsEnabled = IsEnabled,
IsPreferred = preferred,
LanguageCode = LanguageCode,
ForeignType = ForeignType,
Height = Height,
Width = Width,
TMDB_ImageID = TMDB_ImageID,
TmdbCollectionID = TmdbCollectionID,
TmdbCompanyID = TmdbCompanyID,
TmdbEpisodeID = TmdbEpisodeID,
TmdbMovieID = TmdbMovieID,
TmdbNetworkID = TmdbNetworkID,
TmdbPersonID = TmdbPersonID,
TmdbSeasonID = TmdbSeasonID,
TmdbShowID = TmdbShowID,
UserRating = UserRating,
UserVotes = UserVotes,
_width = Width,
_height = Height,
};

#endregion
}

0 comments on commit a95c83a

Please sign in to comment.