Skip to content

Commit c1088a3

Browse files
Add new GetCropUrl overload on UrlHelper for use with local crops
1 parent 6027318 commit c1088a3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Umbraco.Web/UrlHelperRenderExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ public static IHtmlString GetCropUrl(this UrlHelper urlHelper,
237237
return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url);
238238
}
239239

240+
public static IHtmlString GetCropUrl(this UrlHelper urlHelper, ImageCropperValue imageCropperValue, string cropAlias, bool htmlEncode = true)
241+
{
242+
if (imageCropperValue == null) return EmptyHtmlString;
243+
244+
var url = imageCropperValue.Src.GetCropUrl(imageCropperValue, cropAlias: cropAlias, useCropDimensions: true);
245+
return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url);
246+
}
247+
240248
public static IHtmlString GetCropUrl(this UrlHelper urlHelper,
241249
ImageCropperValue imageCropperValue,
242250
int? width = null,

0 commit comments

Comments
 (0)