Copied to clipboard

Flag this post as spam?

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


  • Janelle Torgerson 1 post 22 karma points
    Apr 20, 2014 @ 03:22
    Janelle Torgerson
    0

    Determining if an Image Crop Exists within a Controller: 7.1

    I'm using the new Image Cropper API inside a controller and was wondering what the best way is to determine if an image has a crop or not.

    If you call the GetCropUrl method and an image doesn't have a crop it will return the image url and some padding details appended: /media/1006/picture008.jpg?mode=pad. As a side note, I'm not sure if it should be doing this.

    To distinguish between an image that has the crop I want and one without any crop at all I'm using the following code:

    c var images =
        content.GetProperty("image")
        .GetValue<string>()
        .Split(',')
        .Select(id => Umbraco.TypedMedia(id).GetCropUrl("thumbnail"))
        .Where(image => image.Contains("=crop&"));
    

    Note: I'm using the cropped images with a Multiple Media Picker.

    Is there a better way to do this?

Please Sign in or register to post replies

Write your reply to:

Draft