diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-01-16 00:01:57 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-01-16 00:01:57 -0500 |
| commit | e0f47a4c28867fd07731990e6d0c233f53dc5f17 (patch) | |
| tree | b7173b25e4ba8a87c97b39e16ea4c82d0f8ad439 /MediaBrowser.Server.Implementations | |
| parent | da85e15eb0acb471484b219a510f7dea488e7a4e (diff) | |
add aspect ratio to search results
Diffstat (limited to 'MediaBrowser.Server.Implementations')
3 files changed, 13 insertions, 14 deletions
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index ccca6414a..e47ebc551 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 /// </summary> /// <param name="dto">The dto.</param> /// <param name="item">The item.</param> - /// <param name="fields">The fields.</param> /// <returns>Task.</returns> - public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item, List<ItemFields> 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 3ef625db6..0d588b97b 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> - { - 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 9ffd8a500..04f99cdce 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> - { - ItemFields.PrimaryImageAspectRatio - }); + _dtoService.AttachPrimaryImageAspectRatio(dto, info); } if (currentProgram != null) |
