Copied to clipboard

Flag this post as spam?

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


  • JamesW 18 posts 128 karma points
    Mar 27, 2018 @ 11:46
    JamesW
    0

    Image cropper ordering by width of crop size

    I am using the Nested Content package

    And within in that I have a media picker that is an image which uses a media type that has a set of crops against it.

    I can display the image fine and the image for each crop but I need to order the images by the width of the crop.

    I've tried .OrderBy("width"), .OrderBy(x => x.Width) but get the error:

    ''System.Collections.Generic.List<Umbraco.Web.Models.ImageCropData>' does not contain a definition for 'OrderBy''
    

    Code

    @foreach (var item in Model.Content.SubService)
    {
        string sectionImage = item.GetPropertyValue<string>("image");
        string sectionTitle = item.GetPropertyValue<string>("title");
        string sectionCopy = item.GetPropertyValue<string>("copy");
    
    
    
        // image & crop details
        string ImagePath = "";
        string ImageWidth = "";
        var Image = @Umbraco.Media(sectionImage);
        var FileData = @Image.GetPropertyValue("umbracoFile");
        var ImageCrop = @FileData.Crops;
    
        @foreach (var crop in ImageCrop.OrderBy("width"))
        {
        }
    }
    

    Thanks for any help.

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    Mar 27, 2018 @ 12:50
    Paul Seal
    0

    Have you added a using for Linq?

    @using System.Linq

  • JamesW 18 posts 128 karma points
    Mar 27, 2018 @ 13:21
    JamesW
    0

    Just tried it but no joy.

Please Sign in or register to post replies

Write your reply to:

Draft