Copied to clipboard

Flag this post as spam?

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

  • Jeffrey Weinstein 67 posts 313 karma points
    Jul 19, 2019 @ 14:04
    Jeffrey Weinstein

    Use image cropper inside of Grid's Media editor

    I want to use my image processing pipeline in the Views/Partials/Grid/Editors/Media.cshtml Especially generate several image URLs for img url set, so on each device it would display optimal image. I realized the model is Newtonsoft.Json.Linq.JObject and payload looks something like this

        "value": {
            "id": 2218,
            "udi": "umb://media/c5c48dc6782d48bca2b3366d606d5c09",
            "image": "/media/ycgnjrjn/bali-to-gili-trawangan-fastboat-2.jpg",
            "caption": "Gili Trawangan"
        "editor": {
            "name": "Image",
            "alias": "media",
            "view": "media",
            "render": null,
            "icon": "icon-picture",
            "config": {}

    Can someone please point me to the direction of getting reference of media Item, so I can use

    Url.GetCropUrl(instance, width: 200, height: 100, imageCropMode: ImageCropMode.Max)

    For example..


  • Marc Goodson 2097 posts 13921 karma points MVP 8x c-trib
    Jul 20, 2019 @ 23:40
    Marc Goodson

    Hi Vojtech

    Because you have the 'id' of the media item, you can use the UmbracoHelper's 'Media' method to pull back the full Media Object to then use with Url.GetCropUrl to obtain the different urls for the different crops.

    First thing's first... getting access to the UmbracoHelper in a grid editor partial view, you need to change

    @model dynamic

    at the top of the partial view to be

    @inherits UmbracoViewPage<dynamic>

    This will give you access to the UmbracoHelper via the 'Umbraco' property, and you will be able to write:

      var mediaItem = Umbraco.Media((int);

    to retrieve the full media item to use in conjunction with GetCropUrl eg:

    string croppedMediaUrl = Url.GetCropUrl(mediaItem, width: 200, height: 100, imageCropMode: ImageCropMode.Max)



  • Jeffrey Weinstein 67 posts 313 karma points
    Jul 21, 2019 @ 13:16
    Jeffrey Weinstein

    Thank you very much, you rock!

Please Sign in or register to post replies

Write your reply to: