Update FocalPointPosition and CropCoordinates constructors/properties
This commit is contained in:
@@ -32,7 +32,7 @@ namespace Umbraco.Cms.Core.Models
|
||||
/// </summary>
|
||||
public class FocalPointPosition
|
||||
{
|
||||
public FocalPointPosition(decimal top, decimal left)
|
||||
public FocalPointPosition(decimal left, decimal top)
|
||||
{
|
||||
Left = left;
|
||||
Top = top;
|
||||
@@ -48,21 +48,21 @@ namespace Umbraco.Cms.Core.Models
|
||||
/// </summary>
|
||||
public class CropCoordinates
|
||||
{
|
||||
public CropCoordinates(decimal x1, decimal y1, decimal x2, decimal y2)
|
||||
public CropCoordinates(decimal left, decimal top, decimal right, decimal bottom)
|
||||
{
|
||||
X1 = x1;
|
||||
Y1 = y1;
|
||||
X2 = x2;
|
||||
Y2 = y2;
|
||||
Left = left;
|
||||
Top = top;
|
||||
Right = right;
|
||||
Bottom = bottom;
|
||||
}
|
||||
|
||||
public decimal X1 { get; }
|
||||
public decimal Left { get; }
|
||||
|
||||
public decimal Y1 { get; }
|
||||
public decimal Top { get; }
|
||||
|
||||
public decimal X2 { get; }
|
||||
public decimal Right { get; }
|
||||
|
||||
public decimal Y2 { get; }
|
||||
public decimal Bottom { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Umbraco.Cms.Infrastructure.Media
|
||||
|
||||
if (options.Crop != null)
|
||||
{
|
||||
AddQueryString("crop", options.Crop.X1, options.Crop.Y1, options.Crop.X2, options.Crop.Y2);
|
||||
AddQueryString("crop", options.Crop.Left, options.Crop.Top, options.Crop.Right, options.Crop.Bottom);
|
||||
AddQueryString("cropmode", "percentage");
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Umbraco.Cms.Core.PropertyEditors.ValueConverters
|
||||
{
|
||||
if ((preferFocalPoint && HasFocalPoint()) || (crop != null && crop.Coordinates == null && HasFocalPoint()))
|
||||
{
|
||||
return new ImageUrlGenerationOptions(url) { FocalPoint = new ImageUrlGenerationOptions.FocalPointPosition(FocalPoint.Top, FocalPoint.Left) };
|
||||
return new ImageUrlGenerationOptions(url) { FocalPoint = new ImageUrlGenerationOptions.FocalPointPosition(FocalPoint.Left, FocalPoint.Top) };
|
||||
}
|
||||
else if (crop != null && crop.Coordinates != null && preferFocalPoint == false)
|
||||
{
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.Media
|
||||
{
|
||||
private const string MediaPath = "/media/1005/img_0671.jpg";
|
||||
private static readonly ImageUrlGenerationOptions.CropCoordinates s_crop = new ImageUrlGenerationOptions.CropCoordinates(0.58729977382575338m, 0.055768992440203169m, 0m, 0.32457553600198386m);
|
||||
private static readonly ImageUrlGenerationOptions.FocalPointPosition s_focus1 = new ImageUrlGenerationOptions.FocalPointPosition(0.80827067669172936m, 0.96m);
|
||||
private static readonly ImageUrlGenerationOptions.FocalPointPosition s_focus2 = new ImageUrlGenerationOptions.FocalPointPosition(0.41m, 0.4275m);
|
||||
private static readonly ImageUrlGenerationOptions.FocalPointPosition s_focus1 = new ImageUrlGenerationOptions.FocalPointPosition(0.96m, 0.80827067669172936m);
|
||||
private static readonly ImageUrlGenerationOptions.FocalPointPosition s_focus2 = new ImageUrlGenerationOptions.FocalPointPosition(0.4275m, 0.41m);
|
||||
private static readonly ImageSharpImageUrlGenerator s_generator = new ImageSharpImageUrlGenerator();
|
||||
|
||||
[Test]
|
||||
@@ -71,7 +71,7 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.Media
|
||||
public void GetBaseCropUrlFromModelTest()
|
||||
{
|
||||
var urlString = s_generator.GetImageUrl(new ImageUrlGenerationOptions(null) { Crop = s_crop, Width = 100, Height = 100 });
|
||||
Assert.AreEqual("?crop=0.58729977382575338,0.055768992440203169,0,0.32457553600198386&cropmode=percentage&width=100&height=100", urlString);
|
||||
Assert.AreEqual("?cc=0.58729977382575338,0.055768992440203169,0,0.32457553600198386&width=100&height=100", urlString);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.Common
|
||||
}
|
||||
else if (options.Crop != null)
|
||||
{
|
||||
AddQueryString("c", options.Crop.X1, options.Crop.Y1, options.Crop.X2, options.Crop.Y2);
|
||||
AddQueryString("c", options.Crop.Left, options.Crop.Top, options.Crop.Right, options.Crop.Bottom);
|
||||
}
|
||||
|
||||
if (options.ImageCropMode.HasValue)
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
|
||||
if (focalPointLeft.HasValue && focalPointTop.HasValue)
|
||||
{
|
||||
options.FocalPoint = new ImageUrlGenerationOptions.FocalPointPosition(focalPointTop.Value, focalPointLeft.Value);
|
||||
options.FocalPoint = new ImageUrlGenerationOptions.FocalPointPosition(focalPointLeft.Value, focalPointTop.Value);
|
||||
}
|
||||
else if (cropX1.HasValue && cropX2.HasValue && cropY1.HasValue && cropY2.HasValue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user