Skip to content

Commit

Permalink
Added missing GetCropUrl overload for MediaWithCrops (#11201)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lauraneto authored Oct 10, 2021
1 parent 10d1d3c commit 15aa713
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,60 @@ public static string GetCropUrl(
urlMode
);

/// <summary>
/// Gets the underlying image processing service URL from the MediaWithCrops item.
/// </summary>
/// <param name="mediaWithCrops">The MediaWithCrops item.</param>
/// <param name="width">The width of the output image.</param>
/// <param name="height">The height of the output image.</param>
/// <param name="propertyAlias">Property alias of the property containing the JSON data.</param>
/// <param name="cropAlias">The crop alias.</param>
/// <param name="quality">Quality percentage of the output image.</param>
/// <param name="imageCropMode">The image crop mode.</param>
/// <param name="imageCropAnchor">The image crop anchor.</param>
/// <param name="preferFocalPoint">Use focal point, to generate an output image using the focal point instead of the predefined crop.</param>
/// <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>
/// <param name="cacheBuster">Add a serialized date of the last edit of the item to ensure client cache refresh when updated.</param>
/// <param name="furtherOptions">These are any query string parameters (formatted as query strings) that the underlying image processing service supports. For example:
/// <example><![CDATA[
/// furtherOptions: "bgcolor=fff"
/// ]]></example></param>
/// <param name="urlMode">The url mode.</param>
/// <returns>
/// The URL of the cropped image.
/// </returns>
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
);

/// <summary>
/// Gets the underlying image processing service URL from the image path.
/// </summary>
Expand Down

0 comments on commit 15aa713

Please sign in to comment.