V8 .GetCropUrl("CropAlias") generates invalid ImageProcessor URL
See original GitHub issueIn the process of migrating a v7 website to v8 I came across an issue with “GetCropUrl()”
This code was not providing a cropped/resized image:
featuredPost.BlogPostThumbnail.GetCropUrl("blogThumbnail")
but when I changed it to this:
featuredPost.BlogPostThumbnail.GetCropUrl(610,329)
it worked.
Checking the generated image src urls…
featuredPost.BlogPostThumbnail.GetCropUrl("blogThumbnail")
generates:
/media/4395/shutterstock_256320622_girl-with-tree.jpg?center=0.46832782948063639,0.58439388147611493&mode=crop&width=610&height=329&rnd=132339387248830000
but
featuredPost.BlogPostThumbnail.GetCropUrl("blogThumbnail")
generates:
/media/4395/shutterstock_256320622_girl-with-tree.jpg?crop=0,0.093333333333333338,0,0.097650273224043641&cropmode=percentage&width=610&height=329&rnd=132339387248830000
It seems that those parameters aren’t valid for ImageProcessor. If I edit the url in the HTML via Dev console in the browser, and remove “&width=610&height=329” - the image displays properly.
So, perhaps this is a bug in the v8 implementation of .GetCropUrl(ALIAS)…?
This item has been added to our backlog AB#9962
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (10 by maintainers)
Thanks, @nul800sebastiaan and @warrenbuckley . It looks like the documentation is now matching what Warren suggested, so I guess all is well. 😃
GetCropUrl()
is marked as obsolete already on the ImageCropperValue strongly typed ModelsBuilder object from the PropertyValueConvertor for using an ImageCropper property editor.Changing this functionality from returning just the querystring portion of the URL as opposed to the full image url would be deemed a breaking change and with this already marked as obsolete and the documentation suggesting to use the newer approach with the UrlHelper approach.
https://our.umbraco.com/documentation/getting-started/backoffice/property-editors/built-in-property-editors/image-cropper/#mvc-view-example-to-output-a-banner-crop-from-a-cropper-property-with-the-alias-image
Before (obsolete)
Model.FeaturedImage =
Umbraco.Core.PropertyEditors.ValueConverters.ImageCropperValue
<img src="@Model.FeaturedImage.GetCropUrl("square")" />
After (With new UrlHelper)
Model.FeaturedImage =
Umbraco.Core.PropertyEditors.ValueConverters.ImageCropperValue
<img src="@Url.GetCropUrl(Model.FeaturedImage, cropAlias: "square")" />
I will close this issue, if we need to relook at this then please re-open this with more details