Copied to clipboard

Flag this post as spam?

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


  • Wil Jones 11 posts 31 karma points
    Jul 23, 2015 @ 16:41
    Wil Jones
    0

    GetCropUrl from Umbraco API

    Hello,

    I have a websevice using Umbraco's Web API to lazy load some child nodes content.

    I'm struggling to figure out how to get the CropUrl from the JSON that is saved for the property.

    This is my code.

    var news = help.TypedContent(newsParent).Children().Where("Visible").Select(obj => new NewsItem()
            {
                Name = obj.Name,
                Id = obj.Id,
                PostTitle = obj.GetPropertyValue<string>("postTitle"),
                PostHeroImage = obj.GetCropUrl("postHeroTitle", "Square"),
                URL = obj.Url,
                CreateDate = obj.CreateDate,
                ParentName = obj.Parent.Name
    
            });
    

    The crop's property alias is postHeroTitle.

    Any ideas?

  • Wil Jones 11 posts 31 karma points
    Jul 23, 2015 @ 16:56
    Wil Jones
    0

    I've solved my problem.

    Using the standard obj.GetCropUrl("propertyAlias" , "cropAlias") worked. Updated code below.

    var news = help.TypedContent(newsParent).Children().Where("Visible").Select(obj => new NewsItem()
            {
                Name = obj.Name,
                Id = obj.Id,
                PostTitle = obj.GetPropertyValue<string>("postTitle"),
                PostHeroImage = obj.GetCropUrl("postHeroImage", "16:9"),
                URL = obj.Url,
                CreateDate = obj.CreateDate,
                ParentName = obj.Parent.Name
            });
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies