From ec04469b16e90c58b8a638b00e09098f27112fe5 Mon Sep 17 00:00:00 2001 From: Jeavon Leopold Date: Mon, 21 Apr 2014 09:27:53 +0100 Subject: [PATCH] If only one dimension specified with Ratio mode then assume a square --- src/Umbraco.Web/ImageCropperTemplateExtensions.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/ImageCropperTemplateExtensions.cs b/src/Umbraco.Web/ImageCropperTemplateExtensions.cs index 4a545d69e8..0b645ecc93 100644 --- a/src/Umbraco.Web/ImageCropperTemplateExtensions.cs +++ b/src/Umbraco.Web/ImageCropperTemplateExtensions.cs @@ -265,14 +265,24 @@ namespace Umbraco.Web imageResizerUrl.Append("&height=" + height); } - if (ratioMode == ImageCropRatioMode.Width) + if (ratioMode == ImageCropRatioMode.Width && height != null) { + //if only height specified then assume a sqaure + if (width == null) + { + width = height; + } var widthRatio = (decimal)width/(decimal)height; imageResizerUrl.Append("&widthratio=" + widthRatio.ToString(CultureInfo.InvariantCulture)); } - if (ratioMode == ImageCropRatioMode.Height) + if (ratioMode == ImageCropRatioMode.Height && width != null) { + //if only width specified then assume a sqaure + if (height == null) + { + height = width; + } var heightRatio = (decimal)height/(decimal)width; imageResizerUrl.Append("&heightratio=" + heightRatio.ToString(CultureInfo.InvariantCulture)); }