diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index e9f222016..7b64c0e85 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; +using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Entities.Audio { @@ -52,30 +53,6 @@ namespace MediaBrowser.Controller.Entities.Audio get { return Parent as MusicArtist ?? UnknwonArtist; } } - /// - /// Override to point to first child (song) if not explicitly defined - /// - /// The primary image path. - [IgnoreDataMember] - public override string PrimaryImagePath - { - get - { - if (base.PrimaryImagePath == null) - { - var child = Children.FirstOrDefault(); - - return child == null ? base.PrimaryImagePath : child.PrimaryImagePath; - } - - return base.PrimaryImagePath; - } - set - { - base.PrimaryImagePath = value; - } - } - /// /// Override to point to first child (song) /// @@ -130,6 +107,39 @@ namespace MediaBrowser.Controller.Entities.Audio } } + /// + /// Gets or sets the images. + /// + /// The images. + public override Dictionary Images + { + get + { + var images = base.Images; + string primaryImagePath; + + if (images == null || !images.TryGetValue(ImageType.Primary.ToString(), out primaryImagePath)) + { + var image = Children.Select(c => c.PrimaryImagePath).FirstOrDefault(c => !string.IsNullOrEmpty(c)); + + if (!string.IsNullOrEmpty(image)) + { + if (images == null) + { + images = new Dictionary(); + } + images[ImageType.Primary.ToString()] = image; + } + } + + return images; + } + set + { + base.Images = value; + } + } + /// /// Creates the name of the sort. ///