Fixes U4-4767 and adds a Test for it

This commit is contained in:
Jeavon Leopold
2014-04-27 22:06:48 +01:00
parent e3162d223d
commit 7aa618cbfb
2 changed files with 11 additions and 1 deletions

View File

@@ -92,5 +92,15 @@ namespace Umbraco.Tests.PropertyEditors
var urlString = mediaPath.GetCropUrl(imageCropperValue: cropperJson, width: 300, height: 150, ratioMode: ImageCropRatioMode.Width);
Assert.AreEqual(mediaPath + "?center=0.80827067669172936,0.96&mode=crop&height=150&widthratio=2", urlString);
}
/// <summary>
/// Test that if Crop mode is specified as anything other than Crop the image doesn't use the crop
/// </summary>
[Test]
public void GetCropUrl_SpecifiedCropModeTest()
{
var urlString = mediaPath.GetCropUrl(imageCropperValue: cropperJson, width: 300, height: 150, imageCropMode:ImageCropMode.Max);
Assert.AreEqual(mediaPath + "?mode=max&width=300&height=150", urlString);
}
}
}

View File

@@ -215,7 +215,7 @@ namespace Umbraco.Web
{
var imageResizerUrl = new StringBuilder();
if (string.IsNullOrEmpty(imageCropperValue) == false && imageCropperValue.DetectIsJson())
if (string.IsNullOrEmpty(imageCropperValue) == false && imageCropperValue.DetectIsJson() && (imageCropMode == ImageCropMode.Crop || imageCropMode == null))
{
var cropDataSet = imageCropperValue.SerializeToCropDataSet();
if (cropDataSet != null)