Copied to clipboard

Flag this post as spam?

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


  • John Bergman 483 posts 1132 karma points
    Jul 10, 2017 @ 02:55
    John Bergman
    0

    Using cropper, named crops -- does anyone have this working in 7.6.x?

    I am still struggling in getting the image cropper to work (and yes, I opened a bug report). Has anyone been able to get named crops with a non-default focal point to work? If so, care to share how?

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Jul 10, 2017 @ 08:28
    Dan Diplo
    0

    Hi John. It might help if you shared what code you are using currently to get the crop and explained what isn't working. Errors? Or nothing?

  • John Bergman 483 posts 1132 karma points
    Jul 11, 2017 @ 03:04
    John Bergman
    0

    I defined some pre-defined crops in the Image cropper, for example "masthead".

    I am using 7.6.x with the property converters turned on.

    Here are some of the incantations that do not work (keep in mind there was experimentation going on, so the code is not optimal):

    var tmp = mastHead.mastheadImage.First();
    var mediaItem = Umbraco.TypedMedia(tmp.Id);
    mastHeadImageUrl = Url.GetCropUrl(mediaItem, "masthead").ToString();
    mastHeadImageUrl = mastHead.mastheadImage.First().GetCropUrl(cropAlias:"masthead"); 
    mastHeadImageUrl = mastHead.mastheadImage.First().GetCropUrl(cropAlias: "masthead", preferFocalPoint: true); 
    mastHeadImageUrl = mastHead.mastheadImage.First().GetCropUrl(propertyAlias: "umbracoFile", cropAlias: "masthead");
    

    The image is selected using the media picker, and the actual image resides in the media library. If I try to use the GetCropUrl on the document, (called masthead) like this: mastHeadImageUrl = mastHead.GetCropUrl("mastheadImage", "masthead").ToString();

    I receive "1985?mode=pad&rnd=131394550750000000" 1985 is the MediaId of the image.

  • Rune Hem Strand 147 posts 911 karma points hq c-trib
    Jul 11, 2017 @ 08:48
    Rune Hem Strand
    100

    That is weird!

    I have tried all of your examples and they all work. Well sorta, preferFocalPoint doesn't work and doing .ToString() on the Url helper doesn't make a tonnes of sense :) But in any case, they all returned the correct path to the media item and the correct custom focal point.

    So it seems something else it at play here... Any other details you can share? What type of picker are you using? Is it wrapped in another property editor (NestedContent, ArcheType etc.)?

    This is what I did:

    @{
        var tmp = Model.Content.MyMediapicker.First();
        var imageUrl = Model.Content.MyMediapicker.First().GetCropUrl(cropAlias: "grid");
    }
    <p>@Url.GetCropUrl(tmp, "grid")</p>
    <img src="@Url.GetCropUrl(tmp, "grid")" />
    
    <p>@imageUrl</p>
    <img src="@imageUrl" />
    

    Output: Corpper output

    /Rune

Please Sign in or register to post replies

Write your reply to:

Draft