var backgroundImage = item.GetPropertyValue<string>("image");
var cropName = "CropName";
var imageUrl = "";
var image = Umbraco.TypedMedia(int.Parse(backgroundImage));
var imageCropUrl = image.GetCropUrl(cropName);
imageUrl = imageCropUrl;
So what i usually do is set my Media Type of Image to use the image cropper. Once I have this done I attach the media picker to where ever I need an image and to render it out I use this code
//Gets the Image ID
var backgroundImage = item.GetPropertyValue<string>("image");
//Get the Image Cropper Crop Alias
var cropName = "CropName";
//Set a variable to an empty string;
var imageUrl = "";
//Using the ID we got early turn it into a media item
var image = Umbraco.TypedMedia(int.Parse(backgroundImage));
//Once we have the media item we can get the crop url by getting the crop url name that we specified earlier
var imageCropUrl = image.GetCropUrl(cropName);
//Setting the empty variable that we defined earlier to now contain the image Url
imageUrl = imageCropUrl;
cropping on umbraco 7.3.0
Hello,
I am using image cropper but I am unable to get the link of the cropped image using "GetCropUrl" .
Can someone please help.
Thanks in advance
Hi K,
This is how I usually get the image crop Url.
This works 100% of the time for me.
Nathan
hello ,
I am still having issue to get the cropped url.
I am getting the url as empty
Can someone help.
thanks
Hi k,
Have your site been upgraded from a previous version of Umbraco, if so then I think that you should have a look at this package-
https://our.umbraco.org/projects/collaboration/crop-healer-for-umbraco/
Hope this helps,
/Dennis
hello Denis ,
I am working on umbraco 7.3 and it was not upgraded from a previous version.
Have you perhaps changed some dimension on the crop ? Than you need to run the package Dennis mentioned.
Dave
I have created a new datatype named "newsimage" and choosed Image Cropper as Property editor .
I have also install the package crop healer but cropping still not working.
The image src is empty.
Hi k,
Have you define any crops on the image cropper data type, try to see this documentation https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/image-cropper
Or this uHangout episode. https://www.youtube.com/watch?v=bQsvGmnYaUU
Hope this helps,
/Dennis
Hello denis,
Thank you for your link.
I have followed the steps , but still getting empty src
Please find my code below : foreach(var crop in news.imagenews.crops) { img src="@news.GetCropUrl("imagenews", crop.alias)"
}
Output :
img src
This is not working for me after installation on my laptop.
Is there any fix for image cropper on umrbaco 7.3 ?
Hello nathan,
I am trying your code again but I am stuck here : var image = Umbraco.TypedMedia(int.Parse(backgroundImage));
I am getting rror loading Partial View script.
Can you please help.
Thanks,
Hi K,
So what i usually do is set my Media Type of Image to use the image cropper. Once I have this done I attach the media picker to where ever I need an image and to render it out I use this code
I hope this makes sense?
Nathan
I have created a new data type of type image cropper. I am not using media picker type.
I have used the above code :
var backgroundImage = news.GetPropertyValue
var cropName = "newsimage";
var imageUrl = "";
var image = Umbraco.TypedMedia(int.Parse(backgroundImage));
var imageCropUrl = image.GetCropUrl(cropName);
imageUrl = imageCropUrl;
img src='@imageUrl' />
And i am getting the error : Exception: System.FormatException: Input string was not in a correct format.
is working on a reply...