I installed Umbraco 10.8.2 and created a Doc Type with an Image Cropper by creating a new Data Type. The new version is the same as the original but has additional aliases with different dimensions.
I upload an image via the content section and have the below code in my view
@Model.MyImage.GetCropUrl("DimensionName");
but this doesnt compile. I then tried different variations such as
I think you've created a document type property of
"Image Cropper" - this is supplying to the view a "ImageCropperValue".
You'll notice that the documentation is talking about MediaWithCrops - this has the extension methods you're expecting that will allow you to pass in the single crop alias. ImageCropperValue won't.
Though what you've done is rendering a picker picker in the back office and looks correct I think you'd find it much easier to change to using a "Media Picker".
So the fix is to go to your doc type - add a new property - choose type Media Picker (create new) - then add your crops here.
You'll find the Media Picker v3 much easier to get working. I think what you have is a bit of backwards compatibility legacy. There used to be a helper on Url.GetCropUrl() that made these image croppers work in the doc type but that's missing now I believe.
As the Media Picker is more a v13 way of going I'd do this.
GetCropUrl not working after recent upgrade
Hi
I installed Umbraco 10.8.2 and created a Doc Type with an Image Cropper by creating a new Data Type. The new version is the same as the original but has additional aliases with different dimensions.
I upload an image via the content section and have the below code in my view
but this doesnt compile. I then tried different variations such as
but none seem to work or i get the full image and not the cropped image.
Whats gone wrong?
Are you sure this is an upgrade issue?
I wonder if it's how you're using Razor.
The @ puts Razor into "code mode" - it doesn't require semi colons (like normal c#) but it does need to know where it begins and it ends.
The safest way to do this inline, where there are parenthesis in the code segment, is to wrap the whole statement in parenthesis.
Try:
So if it's in an image tag:
Also note above I've assumed your alias for your crop actually starts with a lowercase letter. Check your crop - it will be case-sensitive.
If the above doesn't work then if there is an exception post the error here and it will give up the issue.
Hi
I tried that but when i copied the code above i left it from a code block.
When i try
The error i receive is
Error (active) CS1501 No overload for method 'GetCropUrl' takes 1 arguments
All the documents and examples ive seen seem to use the above. I also tried
but then i receive
CS1503 Argument 2: cannot convert from 'string' to 'Umbraco.Cms.Core.Media.IImageUrlGenerator'
Does anyone have any idea? I cant tell if im doing something wrong or if im missing something?
That error could suggest you haven’t imported Umbraco extension namespace at the top of the view.
Sorry that too made no difference
With or without that using statement the same error occurred
I think you've created a document type property of "Image Cropper" - this is supplying to the view a "ImageCropperValue".
You'll notice that the documentation is talking about MediaWithCrops - this has the extension methods you're expecting that will allow you to pass in the single crop alias. ImageCropperValue won't.
https://docs.umbraco.com/umbraco-cms/v/10.latest-lts/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/image-cropper
Though what you've done is rendering a picker picker in the back office and looks correct I think you'd find it much easier to change to using a "Media Picker".
So the fix is to go to your doc type - add a new property - choose type Media Picker (create new) - then add your crops here.
You'll find the Media Picker v3 much easier to get working. I think what you have is a bit of backwards compatibility legacy. There used to be a helper on Url.GetCropUrl() that made these image croppers work in the doc type but that's missing now I believe.
As the Media Picker is more a v13 way of going I'd do this.
is working on a reply...