question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

V8 .GetCropUrl("CropAlias") generates invalid ImageProcessor URL

See original GitHub issue

In 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:closed
  • Created 3 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
hfloydcommented, Feb 2, 2021

Thanks, @nul800sebastiaan and @warrenbuckley . It looks like the documentation is now matching what Warren suggested, so I guess all is well. 😃

0reactions
warrenbuckleycommented, Feb 2, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

getcropurl using cropalias generates incorrectly sized image
Has anyone seen this issue? ... So, I've realized that ImageProcessor just isn't getting used at all - there is no "App_Data/cache" folder....
Read more >
Class ImageCropperTemplateExtensions | Umbraco c# Api ...
GetCropUrl (IPublishedContent, String). Gets the ImageProcessor URL by the crop alias (from the "umbracoFile" property alias) on the IPublishedContent item ...
Read more >
Umbraco GetCropUrl not giving me a valid URL with Image ...
In order to get a crop URL for an image in the media section you first ... the same ( umbracoFile ), you...
Read more >
Automatically serving WebP images in Umbraco - kieron.codes
Umbraco ships with Image Processor as part of the core, it's built by ... it with GetCropUrl(cropAlias: "Background", quality: 1) or GetCropUrl(cropAlias: ...
Read more >
Untitled
... of blackheads Automatically resize your media images in Umbraco - codeshare V8 .GetCropUrl ("CropAlias") generates invalid ImageProcessor URL Web25 mar.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found