For a project with a photo carousel I need to know the exact height of the returned crop (uComponents Cropper). So I was wondering if it is possible to get the height of the returned crop, since the cropper sends me some XML info about the original image size and the coordinats about the crop related to the original image. But not about the height of the returned crop.
So I was wondering if this is possible by retrieving all the created crops, and their sizes?
I am using Umbraco 6.1.5 and uComponents 5.4.2.1. And ofcourse I am working in Razor (which is awesome btw)
Firstly, I'm assuming you mean the Core cropper rather than uComponents (I don't think there is one).
There are some handy methods in uComponents developed for XSLT but they are equally helpful in Razor.
Assuming you are using Razor Macros (rather than MVC) then I think this is what you are after?
@inherits umbraco.MacroEngines.DynamicNodeContext
@using uComponents.XsltExtensions;
@{
var mediaItem = Library.MediaById(1067);
if (mediaItem.crops.Count() > 0)
{
var path = mediaItem.crops.Find("@name", "Thumb").url;
var height = Media.GetImageHeight(path);
var width = Media.GetImageWidth(path);
<img src="@path" height="@height" width="@width" />
}
}
Note the @using uComponents.XsltExtensions;
Also, I would highly recommend you use the Image Cropper Extended package instead of using the Core Cropper as it is a much improved and fixed version of what comes by default in Umbraco.
Getting cropper values
Dear Umbraco Users!
For a project with a photo carousel I need to know the exact height of the returned crop (uComponents Cropper). So I was wondering if it is possible to get the height of the returned crop, since the cropper sends me some XML info about the original image size and the coordinats about the crop related to the original image. But not about the height of the returned crop.
So I was wondering if this is possible by retrieving all the created crops, and their sizes?
I am using Umbraco 6.1.5 and uComponents 5.4.2.1.
And ofcourse I am working in Razor (which is awesome btw)
Any help is appreciated!
Greets, Ron
Hi Ron,
Firstly, I'm assuming you mean the Core cropper rather than uComponents (I don't think there is one).
There are some handy methods in uComponents developed for XSLT but they are equally helpful in Razor.
Assuming you are using Razor Macros (rather than MVC) then I think this is what you are after?
Note the
@using uComponents.XsltExtensions;
Also, I would highly recommend you use the Image Cropper Extended package instead of using the Core Cropper as it is a much improved and fixed version of what comes by default in Umbraco.
Jeavon
is working on a reply...