Browse Source

Made test green.

pull/747/head
Sebastian 4 years ago
parent
commit
ac855efec3
  1. 24
      backend/src/Squidex.Domain.Apps.Core.Model/Assets/AssetMetadata.cs
  2. 8
      backend/src/Squidex.Domain.Apps.Entities/Assets/FileTagAssetMetadataSource.cs
  3. 8
      backend/src/Squidex.Domain.Apps.Entities/Assets/ImageAssetMetadataSource.cs

24
backend/src/Squidex.Domain.Apps.Core.Model/Assets/AssetMetadata.cs

@ -68,35 +68,35 @@ namespace Squidex.Domain.Apps.Core.Assets
public float? GetFocusX() public float? GetFocusX()
{ {
return GetNumber(FocusX); return GetSingle(FocusX);
} }
public float? GetFocusY() public float? GetFocusY()
{ {
return GetNumber(FocusY); return GetSingle(FocusY);
} }
public int? GetPixelWidth() public int? GetPixelWidth()
{ {
return GetNumber(PixelWidth); return GetIn32(PixelWidth);
} }
public int? GetPixelHeight() public int? GetPixelHeight()
{ {
return GetNumber(PixelHeight); return GetIn32(PixelHeight);
} }
public int? GetVideoWidth() public int? GetVideoWidth()
{ {
return GetNumber(VideoWidth); return GetIn32(VideoWidth);
} }
public int? GetVideoHeight() public int? GetVideoHeight()
{ {
return GetNumber(VideoHeight); return GetIn32(VideoHeight);
} }
public int? GetNumber(string name) public int? GetIn32(string name)
{ {
if (TryGetValue(name, out var n) && n is JsonNumber number) if (TryGetValue(name, out var n) && n is JsonNumber number)
{ {
@ -106,6 +106,16 @@ namespace Squidex.Domain.Apps.Core.Assets
return null; return null;
} }
public float? GetSingle(string name)
{
if (TryGetValue(name, out var n) && n is JsonNumber number)
{
return (float)number.Value;
}
return null;
}
public bool TryGetNumber(string name, out double result) public bool TryGetNumber(string name, out double result)
{ {
if (TryGetValue(name, out var v) && v is JsonNumber n) if (TryGetValue(name, out var v) && v is JsonNumber n)

8
backend/src/Squidex.Domain.Apps.Entities/Assets/FileTagAssetMetadataSource.cs

@ -153,12 +153,12 @@ namespace Squidex.Domain.Apps.Entities.Assets
{ {
if (asset.Type == AssetType.Video) if (asset.Type == AssetType.Video)
{ {
var videoWidth = asset.Metadata.GetVideoWidth(); var w = asset.Metadata.GetVideoWidth();
var videoHeight = asset.Metadata.GetVideoWidth(); var h = asset.Metadata.GetVideoHeight();
if (videoWidth != null && videoHeight != null) if (w != null && h != null)
{ {
yield return $"{videoHeight}x{videoHeight}pt"; yield return $"{w}x{h}pt";
} }
if (asset.Metadata.TryGetString("duration", out var duration)) if (asset.Metadata.TryGetString("duration", out var duration))

8
backend/src/Squidex.Domain.Apps.Entities/Assets/ImageAssetMetadataSource.cs

@ -123,12 +123,12 @@ namespace Squidex.Domain.Apps.Entities.Assets
{ {
if (asset.Type == AssetType.Image) if (asset.Type == AssetType.Image)
{ {
var pixelWidth = asset.Metadata.GetVideoWidth(); var w = asset.Metadata.GetPixelWidth();
var pixelHeight = asset.Metadata.GetVideoHeight(); var h = asset.Metadata.GetPixelHeight();
if (pixelWidth != null && pixelHeight != null) if (w != null && h != null)
{ {
yield return $"{pixelWidth}x{pixelHeight}px"; yield return $"{w}x{h}px";
} }
} }
} }

Loading…
Cancel
Save