You need to use the crop URL in the Umbraco image. First you need to take out this image as a ipublishedcontent
There are two ways to do this
The first type:
var imageId = model.content.getpropertyvalue<int> ("image") ; var image = Umbraco.typedmedia (imageId);
Second, if you have already used the core property Value converters package, you can take it directly out of
var image = Model.content.getpropertyvalue<ipublishedcontent> ("image");
The method on your image is need to call GetCropUrl()
. If you've replaced the default Upload property with a Image Cropper property, and kept the property alias the same ( umbracoFile
), you can just pass in the crop alias:
var cropUrl = image.GetCropUrl("my-crop-name");
If the alias of your Image Cropper property was different to the default you'll need to pass that as an additional Argume Nt:
var cropUrl = image.GetCropUrl("imageCropperAlias", "my-crop-name");
Use crop URL in Umbraco image