mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-07 11:57:55 +02:00
add aspect ratio to search results
This commit is contained in:
parent
d5b657e2e8
commit
3f8f0ff111
6 changed files with 28 additions and 16 deletions
|
@ -179,6 +179,7 @@ namespace MediaBrowser.Api
|
||||||
if (primaryImageTag != null)
|
if (primaryImageTag != null)
|
||||||
{
|
{
|
||||||
result.PrimaryImageTag = primaryImageTag;
|
result.PrimaryImageTag = primaryImageTag;
|
||||||
|
result.PrimaryImageAspectRatio = _dtoService.GetPrimaryImageAspectRatio(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetThumbImageInfo(result, item);
|
SetThumbImageInfo(result, item);
|
||||||
|
|
|
@ -22,8 +22,14 @@ namespace MediaBrowser.Controller.Dto
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dto">The dto.</param>
|
/// <param name="dto">The dto.</param>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="fields">The fields.</param>
|
void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item);
|
||||||
void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item, List<ItemFields> fields);
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the primary image aspect ratio.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <returns>System.Nullable<System.Double>.</returns>
|
||||||
|
double? GetPrimaryImageAspectRatio(IHasImages item);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the base item dto.
|
/// Gets the base item dto.
|
||||||
|
|
|
@ -144,5 +144,11 @@ namespace MediaBrowser.Model.Search
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The name of the channel.</value>
|
/// <value>The name of the channel.</value>
|
||||||
public string ChannelName { get; set; }
|
public string ChannelName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the primary image aspect ratio.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The primary image aspect ratio.</value>
|
||||||
|
public double? PrimaryImageAspectRatio { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,7 +310,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AttachPrimaryImageAspectRatio(dto, item, fields);
|
AttachPrimaryImageAspectRatio(dto, item);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -1742,15 +1742,19 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dto">The dto.</param>
|
/// <param name="dto">The dto.</param>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="fields">The fields.</param>
|
|
||||||
/// <returns>Task.</returns>
|
/// <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);
|
var imageInfo = item.GetImageInfo(ImageType.Primary, 0);
|
||||||
|
|
||||||
if (imageInfo == null || !imageInfo.IsLocalFile)
|
if (imageInfo == null || !imageInfo.IsLocalFile)
|
||||||
{
|
{
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageSize size;
|
ImageSize size;
|
||||||
|
@ -1762,7 +1766,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
//_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
|
//_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary).ToList();
|
var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary).ToList();
|
||||||
|
@ -1781,8 +1785,9 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
|
|
||||||
if (size.Width > 0 && size.Height > 0)
|
if (size.Width > 0 && size.Height > 0)
|
||||||
{
|
{
|
||||||
dto.PrimaryImageAspectRatio = size.Width / size.Height;
|
return size.Width / size.Height;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,10 +403,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_dtoServiceFactory().AttachPrimaryImageAspectRatio(dto, user, new List<ItemFields>
|
_dtoServiceFactory().AttachPrimaryImageAspectRatio(dto, user);
|
||||||
{
|
|
||||||
ItemFields.PrimaryImageAspectRatio
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -231,10 +231,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||||
{
|
{
|
||||||
dto.ImageTags[ImageType.Primary] = imageTag;
|
dto.ImageTags[ImageType.Primary] = imageTag;
|
||||||
|
|
||||||
_dtoService.AttachPrimaryImageAspectRatio(dto, info, new List<ItemFields>
|
_dtoService.AttachPrimaryImageAspectRatio(dto, info);
|
||||||
{
|
|
||||||
ItemFields.PrimaryImageAspectRatio
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentProgram != null)
|
if (currentProgram != null)
|
||||||
|
|
Loading…
Reference in a new issue