Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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
"caption": "Gili Trawangan"
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)
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
at the top of the partial view to be
This will give you access to the UmbracoHelper via the 'Umbraco' property, and you will be able to write:
var mediaItem = Umbraco.Media((int)Model.value.id);
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)
Thank you very much, you rock!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted