I was trying to use this syntax. Without having to create the predefined crops in the editor. But I never could get it to return anything. I tried both Media and Typed media and just kept drawing blanks. But predefining the crops made it work, so I can move on.
Thank you for your response, though. I really think this should work, but I must be missing something.
Problems with GetCropUrl on Media
Using Umbraco version 7.5.4 assembly: 1.0.6136.27241
Trying to get the GetCropUrl functionality working.
I have a DocumentType that has a Media Picker. I am getting the media items from it and trying to get the cropper url for the items.
I've run across many ways to use the cropper and just can't get the correct thing working.
I can successfully get the media item:
var image = Umbraco.Media(imageList[0]); This gets me image as "Umbraco.Web.Models.DynamicPublishedContent"
If I then do @image.GetCropUrl(200,200) I just get nothing.
I have tried @Url.GetCropUrl and get an error that the UrlHelper doesn't have a method named GetCropUrl.
How is the best way to start with a media id and turn it into a crop url that respects the focal point and allows me to provide a width and height?
Thanks,
Trent
The way I do it (there might be better ways) is like this:
In the media type Image add a crop size under the Image Cropper Mediatype. Give it a name and a width and height.
Then:
This worked like a charm. Thank you!
I believe you need to use TypedMedia to get an IPublishedContent:
I was trying to use this syntax. Without having to create the predefined crops in the editor. But I never could get it to return anything. I tried both Media and Typed media and just kept drawing blanks. But predefining the crops made it work, so I can move on.
Thank you for your response, though. I really think this should work, but I must be missing something.
is working on a reply...