diff --git a/MediaBrowser.Api/SearchService.cs b/MediaBrowser.Api/SearchService.cs
index 9cb699098e..89fc29f3df 100644
--- a/MediaBrowser.Api/SearchService.cs
+++ b/MediaBrowser.Api/SearchService.cs
@@ -179,6 +179,7 @@ namespace MediaBrowser.Api
if (primaryImageTag != null)
{
result.PrimaryImageTag = primaryImageTag;
+ result.PrimaryImageAspectRatio = _dtoService.GetPrimaryImageAspectRatio(item);
}
SetThumbImageInfo(result, item);
diff --git a/MediaBrowser.Controller/Dto/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.cs
index e4ab291025..77a81d0c88 100644
--- a/MediaBrowser.Controller/Dto/IDtoService.cs
+++ b/MediaBrowser.Controller/Dto/IDtoService.cs
@@ -22,8 +22,14 @@ namespace MediaBrowser.Controller.Dto
///
/// The dto.
/// The item.
- /// The fields.
- void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item, List fields);
+ void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item);
+
+ ///
+ /// Gets the primary image aspect ratio.
+ ///
+ /// The item.
+ /// System.Nullable<System.Double>.
+ double? GetPrimaryImageAspectRatio(IHasImages item);
///
/// Gets the base item dto.
diff --git a/MediaBrowser.Model/Search/SearchHint.cs b/MediaBrowser.Model/Search/SearchHint.cs
index d51c0325db..3a1d45cc43 100644
--- a/MediaBrowser.Model/Search/SearchHint.cs
+++ b/MediaBrowser.Model/Search/SearchHint.cs
@@ -144,5 +144,11 @@ namespace MediaBrowser.Model.Search
///
/// The name of the channel.
public string ChannelName { get; set; }
+
+ ///
+ /// Gets or sets the primary image aspect ratio.
+ ///
+ /// The primary image aspect ratio.
+ public double? PrimaryImageAspectRatio { get; set; }
}
}
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
index ccca6414a7..e47ebc5512 100644
--- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs
+++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
@@ -305,7 +305,7 @@ namespace MediaBrowser.Server.Implementations.Dto
{
try
{
- AttachPrimaryImageAspectRatio(dto, item, fields);
+ AttachPrimaryImageAspectRatio(dto, item);
}
catch (Exception ex)
{
@@ -1745,15 +1745,19 @@ namespace MediaBrowser.Server.Implementations.Dto
///
/// The dto.
/// The item.
- /// The fields.
/// Task.
- public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item, List fields)
+ public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item)
+ {
+ dto.PrimaryImageAspectRatio = GetPrimaryImageAspectRatio(item);
+ }
+
+ public double? GetPrimaryImageAspectRatio(IHasImages item)
{
var imageInfo = item.GetImageInfo(ImageType.Primary, 0);
if (imageInfo == null || !imageInfo.IsLocalFile)
{
- return;
+ return null;
}
ImageSize size;
@@ -1765,7 +1769,7 @@ namespace MediaBrowser.Server.Implementations.Dto
catch (Exception ex)
{
//_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
- return;
+ return null;
}
var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary).ToList();
@@ -1784,8 +1788,9 @@ namespace MediaBrowser.Server.Implementations.Dto
if (size.Width > 0 && size.Height > 0)
{
- dto.PrimaryImageAspectRatio = size.Width / size.Height;
+ return size.Width / size.Height;
}
+ return null;
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs
index 3ef625db67..0d588b97bb 100644
--- a/MediaBrowser.Server.Implementations/Library/UserManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs
@@ -403,10 +403,7 @@ namespace MediaBrowser.Server.Implementations.Library
try
{
- _dtoServiceFactory().AttachPrimaryImageAspectRatio(dto, user, new List
- {
- ItemFields.PrimaryImageAspectRatio
- });
+ _dtoServiceFactory().AttachPrimaryImageAspectRatio(dto, user);
}
catch (Exception ex)
{
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs
index 9ffd8a500e..04f99cdce9 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs
@@ -231,10 +231,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{
dto.ImageTags[ImageType.Primary] = imageTag;
- _dtoService.AttachPrimaryImageAspectRatio(dto, info, new List
- {
- ItemFields.PrimaryImageAspectRatio
- });
+ _dtoService.AttachPrimaryImageAspectRatio(dto, info);
}
if (currentProgram != null)