From 7404ccf02428be01de392ae41cdd880b8eadab1d Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Mon, 23 Sep 2019 14:47:41 +0100 Subject: [PATCH] C# change to append/perist the width & height into the pasted/dragged image to the image src url for ImageProcessor resizing --- src/Umbraco.Web/Templates/TemplateUtilities.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Templates/TemplateUtilities.cs b/src/Umbraco.Web/Templates/TemplateUtilities.cs index edccbcc9d4..bc34dbdda7 100644 --- a/src/Umbraco.Web/Templates/TemplateUtilities.cs +++ b/src/Umbraco.Web/Templates/TemplateUtilities.cs @@ -237,9 +237,19 @@ namespace Umbraco.Web.Templates var udi = mediaFile.GetUdi(); img.SetAttributeValue("data-udi", udi.ToString()); - //Get the new persisted image url + // Get the new persisted image url var mediaTyped = Current.UmbracoHelper.Media(mediaFile.Id); var location = mediaTyped.Url; + + // Find the width & height attributes as we need to set the imageprocessor QueryString + var width = img.GetAttributeValue("width", int.MinValue); + var height = img.GetAttributeValue("height", int.MinValue); + + if(width != int.MinValue && height != int.MinValue) + { + location = $"{location}?width={width}&height={height}&mode=max"; + } + img.SetAttributeValue("src", location); // Remove the data attribute (so we do not re-process this)