From 15aa713d2ab0861b54b4af089c7117f3611d79e5 Mon Sep 17 00:00:00 2001 From: Laura Neto <12862535+lauraneto@users.noreply.github.com> Date: Mon, 11 Oct 2021 01:36:14 +0200 Subject: [PATCH] Added missing GetCropUrl overload for MediaWithCrops (#11201) * Added missing GetCropUrl overload for MediaWithCrops with the extra configuration options The missing overload would mean that if anyone tried to use the extra options with MediaWithCrops, they would be using the IPublishedContent extension method instead. This would cause several issues, like not loading the local crops and returning null for a lot of scenarios that should work. * Added documentation to the added overload * Use extension method --- .../FriendlyImageCropperTemplateExtensions.cs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs b/src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs index 22ddc1551189..cbce607b326e 100644 --- a/src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs @@ -126,6 +126,60 @@ public static string GetCropUrl( urlMode ); + /// + /// Gets the underlying image processing service URL from the MediaWithCrops item. + /// + /// The MediaWithCrops item. + /// The width of the output image. + /// The height of the output image. + /// Property alias of the property containing the JSON data. + /// The crop alias. + /// Quality percentage of the output image. + /// The image crop mode. + /// The image crop anchor. + /// Use focal point, to generate an output image using the focal point instead of the predefined crop. + /// Use crop dimensions to have the output image sized according to the predefined crop sizes, this will override the width and height parameters. + /// Add a serialized date of the last edit of the item to ensure client cache refresh when updated. + /// These are any query string parameters (formatted as query strings) that the underlying image processing service supports. For example: + /// + /// The url mode. + /// + /// The URL of the cropped image. + /// + public static string GetCropUrl( + this MediaWithCrops mediaWithCrops, + int? width = null, + int? height = null, + string propertyAlias = Cms.Core.Constants.Conventions.Media.File, + string cropAlias = null, + int? quality = null, + ImageCropMode? imageCropMode = null, + ImageCropAnchor? imageCropAnchor = null, + bool preferFocalPoint = false, + bool useCropDimensions = false, + bool cacheBuster = true, + string furtherOptions = null, + UrlMode urlMode = UrlMode.Default) + => mediaWithCrops.GetCropUrl( + ImageUrlGenerator, + PublishedValueFallback, + PublishedUrlProvider, + width, + height, + propertyAlias, + cropAlias, + quality, + imageCropMode, + imageCropAnchor, + preferFocalPoint, + useCropDimensions, + cacheBuster, + furtherOptions, + urlMode + ); + /// /// Gets the underlying image processing service URL from the image path. ///