I have a Partial View which renders a Feature Box on my homepage.
These feature boxes are selected via a MNTP on my homepage doctype.
I'm trying to get the image to display via Image Cropper but keep getting this error.
The value of parameter 'id' must be either a string or an integer
My Partial View code is
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@*
This snippet lists the items from a Multinode tree picker, using the pickers default settings.
Content Values stored as xml.
To get it working with any site's data structure, set the selection equal to the property which has the
multinode treepicker (so: replace "PropertyWithPicker" with the alias of your property).
*@
@{ var selection = CurrentPage.FeaturesToHighlight; }
<div class="feature-boxes">
<div class="row no-gutter">
@foreach(var item in selection)
{
<div class="col-sm-4">
<div class="feature-box">
<a href="@item.Link.Url">
@{
if (item.HasValue("image")) {
var featureImage = Umbraco.Media(item.Image);
<img src="@featureImage.GetCropUrl("featureBox")" alt="" class="img-responsive" />
}
}
<h2>@item.Heading</h2>
<p>@item.SubHeading</p>
</a>
</div>
</div>
}
</div>
</div>
Some Background Info
I've been following along with Jeavon's example in uHangout Ep30.
Have changed my Image Media Type from Upload to Image Cropper.
Have set a crop called 'featureBox'
My media picker alias on my feature box doctype is 'image'
GetCropUrl and Umbraco.Media
I have a Partial View which renders a Feature Box on my homepage. These feature boxes are selected via a MNTP on my homepage doctype.
I'm trying to get the image to display via Image Cropper but keep getting this error.
My Partial View code is
Some Background Info
Can anyone help?
I'm not sure this is the issue yet but you need to put brackets around the razor that is trying to get the crop URL. e.g.
I suspect your actual problem is this line:
If you comment out the two lines noted and just do:
what is output? If it's not an ID then you need to work on that. Is it a list of IDs - take a look at this if so Media Picker
Hi Ajay
Do what does it render when you output
Maybe you have the Core PropertyValue Convertors package installed : https://our.umbraco.org/projects/developer-tools/umbraco-core-property-value-converters/
If that's the case item.Image will return the media item instead of the id and you can do this :
Dave
I indeed have got Core Property Value Converters installed.
Your solution has worked.
Thank you
Hi,
Sorry - just re-read your full post.
Won't this just work?
That is what I thought would work too but that renders the image src as
Dave's solution above has fixed things.
is working on a reply...