Skip to content

Commit 15aa713

Browse files
authored
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
1 parent 10d1d3c commit 15aa713

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,60 @@ public static string GetCropUrl(
126126
urlMode
127127
);
128128

129+
/// <summary>
130+
/// Gets the underlying image processing service URL from the MediaWithCrops item.
131+
/// </summary>
132+
/// <param name="mediaWithCrops">The MediaWithCrops item.</param>
133+
/// <param name="width">The width of the output image.</param>
134+
/// <param name="height">The height of the output image.</param>
135+
/// <param name="propertyAlias">Property alias of the property containing the JSON data.</param>
136+
/// <param name="cropAlias">The crop alias.</param>
137+
/// <param name="quality">Quality percentage of the output image.</param>
138+
/// <param name="imageCropMode">The image crop mode.</param>
139+
/// <param name="imageCropAnchor">The image crop anchor.</param>
140+
/// <param name="preferFocalPoint">Use focal point, to generate an output image using the focal point instead of the predefined crop.</param>
141+
/// <param name="useCropDimensions">Use crop dimensions to have the output image sized according to the predefined crop sizes, this will override the width and height parameters.</param>
142+
/// <param name="cacheBuster">Add a serialized date of the last edit of the item to ensure client cache refresh when updated.</param>
143+
/// <param name="furtherOptions">These are any query string parameters (formatted as query strings) that the underlying image processing service supports. For example:
144+
/// <example><![CDATA[
145+
/// furtherOptions: "bgcolor=fff"
146+
/// ]]></example></param>
147+
/// <param name="urlMode">The url mode.</param>
148+
/// <returns>
149+
/// The URL of the cropped image.
150+
/// </returns>
151+
public static string GetCropUrl(
152+
this MediaWithCrops mediaWithCrops,
153+
int? width = null,
154+
int? height = null,
155+
string propertyAlias = Cms.Core.Constants.Conventions.Media.File,
156+
string cropAlias = null,
157+
int? quality = null,
158+
ImageCropMode? imageCropMode = null,
159+
ImageCropAnchor? imageCropAnchor = null,
160+
bool preferFocalPoint = false,
161+
bool useCropDimensions = false,
162+
bool cacheBuster = true,
163+
string furtherOptions = null,
164+
UrlMode urlMode = UrlMode.Default)
165+
=> mediaWithCrops.GetCropUrl(
166+
ImageUrlGenerator,
167+
PublishedValueFallback,
168+
PublishedUrlProvider,
169+
width,
170+
height,
171+
propertyAlias,
172+
cropAlias,
173+
quality,
174+
imageCropMode,
175+
imageCropAnchor,
176+
preferFocalPoint,
177+
useCropDimensions,
178+
cacheBuster,
179+
furtherOptions,
180+
urlMode
181+
);
182+
129183
/// <summary>
130184
/// Gets the underlying image processing service URL from the image path.
131185
/// </summary>

0 commit comments

Comments
 (0)