@@ -33,10 +33,25 @@ public static string GetCropUrl(this MediaWithCrops mediaWithCrops, string cropA
3333 return mediaWithCrops . GetCropUrl ( imageUrlGenerator , cropAlias : cropAlias , useCropDimensions : true ) ;
3434 }
3535
36- [ Obsolete ( "This method does not get the crops or cache buster value from the media item." ) ]
36+ [ Obsolete ( "Use the GetCropUrl overload with the updated parameter order and note this implementation has changed to get the URL from the media item." ) ]
3737 public static string GetCropUrl ( this IPublishedContent mediaItem , string cropAlias , IImageUrlGenerator imageUrlGenerator , ImageCropperValue imageCropperValue )
3838 {
39- return mediaItem . Url ( ) . GetCropUrl ( imageUrlGenerator , imageCropperValue , cropAlias : cropAlias , useCropDimensions : true ) ;
39+ return mediaItem . GetCropUrl ( imageCropperValue , cropAlias , imageUrlGenerator ) ;
40+ }
41+
42+ /// <summary>
43+ /// Gets the crop URL by using only the specified <paramref name="imageCropperValue" />.
44+ /// </summary>
45+ /// <param name="mediaItem">The media item.</param>
46+ /// <param name="imageCropperValue">The image cropper value.</param>
47+ /// <param name="cropAlias">The crop alias.</param>
48+ /// <param name="imageUrlGenerator">The image URL generator.</param>
49+ /// <returns>
50+ /// The image crop URL.
51+ /// </returns>
52+ public static string GetCropUrl ( this IPublishedContent mediaItem , ImageCropperValue imageCropperValue , string cropAlias , IImageUrlGenerator imageUrlGenerator )
53+ {
54+ return mediaItem . GetCropUrl ( imageUrlGenerator , imageCropperValue , true , cropAlias : cropAlias , useCropDimensions : true ) ;
4055 }
4156
4257 /// <summary>
@@ -134,7 +149,7 @@ public static string GetCropUrl(
134149 ImageCropRatioMode ? ratioMode = null ,
135150 bool upScale = true )
136151 {
137- return mediaItem . GetCropUrl ( imageUrlGenerator , null , width , height , propertyAlias , cropAlias , quality , imageCropMode , imageCropAnchor , preferFocalPoint , useCropDimensions , cacheBuster , furtherOptions , ratioMode , upScale ) ;
152+ return mediaItem . GetCropUrl ( imageUrlGenerator , null , false , width , height , propertyAlias , cropAlias , quality , imageCropMode , imageCropAnchor , preferFocalPoint , useCropDimensions , cacheBuster , furtherOptions , ratioMode , upScale ) ;
138153 }
139154
140155 public static string GetCropUrl (
@@ -154,28 +169,31 @@ public static string GetCropUrl(
154169 ImageCropRatioMode ? ratioMode = null ,
155170 bool upScale = true )
156171 {
157- return mediaWithCrops . MediaItem . GetCropUrl ( imageUrlGenerator , mediaWithCrops . LocalCrops , width , height , propertyAlias , cropAlias , quality , imageCropMode , imageCropAnchor , preferFocalPoint , useCropDimensions , cacheBuster , furtherOptions , ratioMode , upScale ) ;
172+ if ( mediaWithCrops == null ) throw new ArgumentNullException ( nameof ( mediaWithCrops ) ) ;
173+
174+ return mediaWithCrops . Content . GetCropUrl ( imageUrlGenerator , mediaWithCrops . LocalCrops , false , width , height , propertyAlias , cropAlias , quality , imageCropMode , imageCropAnchor , preferFocalPoint , useCropDimensions , cacheBuster , furtherOptions , ratioMode , upScale ) ;
158175 }
159176
160177 private static string GetCropUrl (
161178 this IPublishedContent mediaItem ,
162179 IImageUrlGenerator imageUrlGenerator ,
163180 ImageCropperValue localCrops ,
164- int ? width ,
165- int ? height ,
166- string propertyAlias ,
167- string cropAlias ,
168- int ? quality ,
169- ImageCropMode ? imageCropMode ,
170- ImageCropAnchor ? imageCropAnchor ,
171- bool preferFocalPoint ,
172- bool useCropDimensions ,
173- bool cacheBuster ,
174- string furtherOptions ,
175- ImageCropRatioMode ? ratioMode ,
176- bool upScale )
181+ bool localCropsOnly ,
182+ int ? width = null ,
183+ int ? height = null ,
184+ string propertyAlias = Constants . Conventions . Media . File ,
185+ string cropAlias = null ,
186+ int ? quality = null ,
187+ ImageCropMode ? imageCropMode = null ,
188+ ImageCropAnchor ? imageCropAnchor = null ,
189+ bool preferFocalPoint = false ,
190+ bool useCropDimensions = false ,
191+ bool cacheBuster = true ,
192+ string furtherOptions = null ,
193+ ImageCropRatioMode ? ratioMode = null ,
194+ bool upScale = true )
177195 {
178- if ( mediaItem == null ) throw new ArgumentNullException ( " mediaItem" ) ;
196+ if ( mediaItem == null ) throw new ArgumentNullException ( nameof ( mediaItem ) ) ;
179197
180198 var cacheBusterValue = cacheBuster ? mediaItem . UpdateDate . ToFileTimeUtc ( ) . ToString ( CultureInfo . InvariantCulture ) : null ;
181199
@@ -184,8 +202,8 @@ private static string GetCropUrl(
184202
185203 var mediaItemUrl = mediaItem . MediaUrl ( propertyAlias : propertyAlias ) ;
186204
187- // Only get crops when used
188- if ( imageCropMode == ImageCropMode . Crop || imageCropMode == null )
205+ // Only get crops from media when required and used
206+ if ( localCropsOnly == false && ( imageCropMode == ImageCropMode . Crop || imageCropMode == null ) )
189207 {
190208 // Get the default cropper value from the value converter
191209 var cropperValue = mediaItem . Value ( propertyAlias ) ;
0 commit comments