From 29dbc2f631eddc0bba60fe03be169ba090581543 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 3 May 2013 14:33:47 -0400 Subject: [PATCH] support image types on general images --- MediaBrowser.Api/Images/ImageByNameService.cs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/MediaBrowser.Api/Images/ImageByNameService.cs b/MediaBrowser.Api/Images/ImageByNameService.cs index 2ab3560b2..d1baf5683 100644 --- a/MediaBrowser.Api/Images/ImageByNameService.cs +++ b/MediaBrowser.Api/Images/ImageByNameService.cs @@ -8,9 +8,9 @@ namespace MediaBrowser.Api.Images /// /// Class GetGeneralImage /// - [Route("/Images/General/{Name}", "GET")] + [Route("/Images/General/{Name}/{Type}", "GET")] [Api(Description = "Gets a general image by name")] - public class GetGeneralImage : ImageRequest + public class GetGeneralImage { /// /// Gets or sets the name. @@ -18,6 +18,9 @@ namespace MediaBrowser.Api.Images /// The name. [ApiMember(Name = "Name", Description = "The name of the image", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] public string Name { get; set; } + + [ApiMember(Name = "Type", Description = "Image Type (primary, backdrop, logo, etc).", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Type { get; set; } } /// @@ -25,7 +28,7 @@ namespace MediaBrowser.Api.Images /// [Route("/Images/Ratings/{Theme}/{Name}", "GET")] [Api(Description = "Gets a rating image by name")] - public class GetRatingImage : ImageRequest + public class GetRatingImage { /// /// Gets or sets the name. @@ -47,7 +50,7 @@ namespace MediaBrowser.Api.Images /// [Route("/Images/MediaInfo/{Theme}/{Name}", "GET")] [Api(Description = "Gets a media info image by name")] - public class GetMediaInfoImage : ImageRequest + public class GetMediaInfoImage { /// /// Gets or sets the name. @@ -90,7 +93,11 @@ namespace MediaBrowser.Api.Images /// System.Object. public object Get(GetGeneralImage request) { - var file = Path.Combine(_appPaths.GeneralPath, request.Name, "folder.jpg"); + var filename = string.Equals(request.Type, "primary", System.StringComparison.OrdinalIgnoreCase) + ? "folder" + : request.Type; + + var file = Path.Combine(_appPaths.GeneralPath, request.Name, filename + ".jpg"); return ToStaticFileResult(File.Exists(file) ? file : Path.ChangeExtension(file, ".png")); } @@ -168,12 +175,12 @@ namespace MediaBrowser.Api.Images return ToStaticFileResult(file); } } - + var allFolder = Path.Combine(_appPaths.MediaInfoImagesPath, "all"); if (Directory.Exists(allFolder)) { - var file = Path.Combine(allFolder, request.Name + ".png"); + var file = Path.Combine(allFolder, request.Name + ".png"); if (File.Exists(file)) {