mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-04 18:09:12 +03:00
[PR #15071] Fix backdrop image ordering regression in EF Core migration #14230
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/jellyfin/jellyfin/pull/15071
Author: @seeyabye
Created: 10/21/2025
Status: 🔄 Open
Base:
release-10.11.z← Head:fix-backdrop-image-ordering📝 Commits (10+)
0ddc948Fix backdrop image ordering regression after EF Core migration by implementing runtime sorting that matches LocalImageProvider discovery order7c0b011Add database-level SortOrder for backdrop images8f0e090Improve PopulateImageSortOrder migration with async and memory efficiencybbf56daChanged composite index to include ImageType5b653e5Prepoluate SortOrder before correction8ac3d08Changed SaveImage logic5b6c9ebFixed SortOrder not being populated on new scans888170bCleanupaac467fFixed SortOrder for Web Uploads8d7237bFixed AddImage's ordering to ensure consistency📊 Changes
12 files changed (+2380 additions, -30 deletions)
View changed files
📝
Jellyfin.Server.Implementations/Item/BaseItemRepository.cs(+123 -8)➕
Jellyfin.Server/Migrations/Routines/PopulateImageSortOrder.cs(+253 -0)📝
MediaBrowser.Controller/Entities/BaseItem.cs(+95 -19)📝
MediaBrowser.Controller/Entities/ItemImageInfo.cs(+7 -0)📝
MediaBrowser.Controller/Persistence/IItemRepository.cs(+10 -0)➕
MediaBrowser.Controller/Utilities/ImageOrderingUtilities.cs(+53 -0)📝
MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs(+15 -1)📝
src/Jellyfin.Database/Jellyfin.Database.Implementations/Entities/BaseItemImageInfo.cs(+8 -0)➕
src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/BaseItemImageInfoConfiguration.cs(+22 -0)➕
src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/20251022214259_AddSortOrderToBaseItemImageInfo.Designer.cs(+1724 -0)➕
src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/20251022214259_AddSortOrderToBaseItemImageInfo.cs(+65 -0)📝
src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/JellyfinDbModelSnapshot.cs(+5 -2)📄 Description
Issue
After migrating from SQLite direct queries to Entity Framework Core, backdrop images are no longer displayed in the correct order. Specifically,
fanart.jpg(which should have priority) is often displayed after images from theextrafanart/folder.This affects the display when "Select view" is set to "Thumb" or "Thumb Card", the backdrop image shown becomes unpredictable.
Root Cause
In v10.10.7:
In current main (EF Core):
BaseItemImageInfostable without an explicit order columnOrderByclause was specifiedextrafanart/fanart1.jpgsorts beforefanart.jpgalphabeticallySolution
Implements priority-based sorting that matches the
LocalImageProviderdiscovery order:{mediaFileName}-fanart.jpg(highest priority)fanart.jpg(not in extrafanart folder)fanart-N.jpg(numbered backdrops)background.jpg/background-N.jpgart.jpg/art-N.jpgextrafanart/*folder contents (alphabetical)backdrop.jpg/backdropN.jpgWithin each priority group, images are sorted by numeric index (if present) and then alphabetically by path for stability.
Changes
Jellyfin.Server.Implementations/Item/BaseItemRepository.csGetImageOrderPriority()helper method to determine priority based on filename patternsGetNumericImageIndex()helper method to extract numeric indices from filenamesTesting
With a file structure like:
Before:
extrafanart/fanart1.jpgoften displayed firstAfter:
fanart.jpgcorrectly displays first🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.