In Umbraco 8.02 I have some trouble getting an image with GetCropUrl.
I have a macro from a Umbraco template and the content type has a crop image.
Listing the nodes is no problem, just the right crop url.
Below is the code I use with some comments. I tried to convert the field value (to what?) and call Url.GetCropUrl. All lead to an empty value or an error message.
Someone is able to help me with this?
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using Umbraco.Web
@* Get the starting page *@
var startNode = Umbraco.Content(startNodeId);
var selection = startNode.Children.Where(x => x.IsVisible()).ToArray();
if (selection.Length > 0)
{
<div class="row">
@foreach (var item in selection)
{
var image = item.Value<string>("headerImage"); // string returns json, without type it returns Umbraco.Core.PropertyEditors.ValueConverters.ImageCropperValue
<div class="col-md-4">
@image -> Image url
@image.GetCropUrl("overview") -> error
@Url.GetCropUrl("headerImage", "overview") -> error
<p><a href="@item.Url">@item.Name</a></p>
</div>
}
</div>
}
GetCropUrl in a selection in a macro
In Umbraco 8.02 I have some trouble getting an image with GetCropUrl. I have a macro from a Umbraco template and the content type has a crop image. Listing the nodes is no problem, just the right crop url. Below is the code I use with some comments. I tried to convert the field value (to what?) and call Url.GetCropUrl. All lead to an empty value or an error message. Someone is able to help me with this?
Hi Tobi
I think you should get the image value as
ImageCropperValue
. Then you should be able to use theGetCropUrl
overload.Hi Søren
Thanks, this did the trick. Didn't think about typing it explicitly.
is working on a reply...