diff options
| author | Cody Robibero <cody@robibe.ro> | 2021-12-24 02:02:37 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-24 02:02:37 +0000 |
| commit | 8c7dd0a691d150ac4fa5719853554ff569abf1bb (patch) | |
| tree | 9f1c8ed8b9b2c8c0dc4d61d37389b6414bb829b4 /Emby.Server.Implementations/Dto | |
| parent | 55b429edb7129e94a4f8e0ee507c26a76717ce4a (diff) | |
| parent | 5d19c26d5966db3ff48c73f409290509815cd89a (diff) | |
Merge pull request #6819 from cvium/why_should_we_use_the_imageinfo_when_we_can_guess
Diffstat (limited to 'Emby.Server.Implementations/Dto')
| -rw-r--r-- | Emby.Server.Implementations/Dto/DtoService.cs | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 365aa8368..a6406827c 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1404,44 +1404,27 @@ namespace Emby.Server.Implementations.Dto return null; } - ImageDimensions size; - - var defaultAspectRatio = item.GetDefaultPrimaryImageAspectRatio(); - - if (defaultAspectRatio > 0) - { - return defaultAspectRatio; - } - if (!imageInfo.IsLocalFile) { - return null; + return item.GetDefaultPrimaryImageAspectRatio(); } try { - size = _imageProcessor.GetImageDimensions(item, imageInfo); - - if (size.Width <= 0 || size.Height <= 0) + var size = _imageProcessor.GetImageDimensions(item, imageInfo); + var width = size.Width; + var height = size.Height; + if (width > 0 && height > 0) { - return null; + return (double)width / height; } } catch (Exception ex) { - _logger.LogError(ex, "Failed to determine primary image aspect ratio for {0}", imageInfo.Path); - return null; - } - - var width = size.Width; - var height = size.Height; - - if (width <= 0 || height <= 0) - { - return null; + _logger.LogError(ex, "Failed to determine primary image aspect ratio for {ImagePath}", imageInfo.Path); } - return (double)width / height; + return item.GetDefaultPrimaryImageAspectRatio(); } } } |
