From 3314a0f69ac902190a5788bbc5a7bc8dd1a4c5ad Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 5 Apr 2013 00:10:23 -0400 Subject: [PATCH] #105 - MusicAlbum items give no PrimaryImage in API when one exists --- .../Entities/Audio/MusicAlbum.cs | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index e9f2220165..7b64c0e854 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. ///