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
    May 17, 2017 @ 05:21
    John Bergman
    0

    Perplexed by GetCropUrl in 7.6

    I went back add added crop aliases to the media library; I can see them when I look at the media item, and they are responsive based on the focal point.

    However, I have been unable to determine the magical incantation to fetch the crop with the focal point. It appears to use the ImageCropAnchor no matter what. The name of my crop setting is "masthead"

    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.

    Can anyone point me in the right direction here?

  • Anders Brohus 194 posts 475 karma points
    May 17, 2017 @ 06:21
    Anders Brohus
    0

    Hi John :)

    I'm not sure if you are trying to get the Cropped Url or something else? :) But if it's just the cropped url i would do this .. :)

    var backgroundImage = Umbraco.Media(MEDIA-ID).GetCropUrl("NAME-OF-CROP");
    
  • John Bergman 483 posts 1132 karma points
    May 17, 2017 @ 06:29
    John Bergman
    0

    Hi Anders,

    I want the cropped Url, but I need it to use the focal point.

    The incantations above all give a cropped url, but it is not paying attention to the focal point set in the media library.

    Bug opened: http://issues.umbraco.org/issue/U4-9942

Please Sign in or register to post replies

Write your reply to:

Draft