Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Linx 98 posts 258 karma points
    Dec 16, 2023 @ 14:35

    GetCropUrl not working after recent upgrade


    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

    @Model.MyImage.GetCropUrl("myImage", "DimensionName");

    but none seem to work or i get the full image and not the cropped image.

    Whats gone wrong?

  • Steve Morgan 1346 posts 4455 karma points c-trib
    Dec 18, 2023 @ 17:36
    Steve Morgan

    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.



    So if it's in an image tag:

    <img src="@(Model.MyImage.GetCropUrl("dimensionName"))" class"myclass"/>

    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.

  • Steve Morgan 1346 posts 4455 karma points c-trib
    Dec 18, 2023 @ 17:37
    Steve Morgan

    If the above doesn't work then if there is an exception post the error here and it will give up the issue.

  • Linx 98 posts 258 karma points
    Dec 19, 2023 @ 10:59


    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

    @Model.MyImage.GetCropUrl("myImage", "DimensionName")

    but then i receive

    CS1503 Argument 2: cannot convert from 'string' to 'Umbraco.Cms.Core.Media.IImageUrlGenerator'

  • Linx 98 posts 258 karma points
    Dec 21, 2023 @ 15:48

    Does anyone have any idea? I cant tell if im doing something wrong or if im missing something?

  • Brendan Rice 538 posts 1100 karma points
    Dec 21, 2023 @ 17:47
    Brendan Rice

    That error could suggest you haven’t imported Umbraco extension namespace at the top of the view.

    @using Umbraco.Extensions
  • Linx 98 posts 258 karma points
    Dec 22, 2023 @ 10:36

    Sorry that too made no difference

    With or without that using statement the same error occurred

    enter image description here

  • Steve Morgan 1346 posts 4455 karma points c-trib
    Dec 29, 2023 @ 09:33
    Steve Morgan

    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.

Please Sign in or register to post replies

Write your reply to: