Media Picker Dynamic foreach loop not working? (Umbraco v7.6)
I can't get even the most basic of examples running using the Media Picker "Dynamic" example supplied in umbraco.org's media picker documentation.
I keep getting this error:
System.Collections.Generic.List
I can get the "Typed" version to work without any issues, but only if the media picker does NOT allow multiple items to be checked. After a long and exhausting search I still cannot find a solution.
Here's a copy of the code I'm working with:
@if (CurrentPage.HasValue("sliderPictures"))
{
var caseStudyImagesList = CurrentPage.sliderPictures.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var caseStudyImagesCollection = Umbraco.Media(caseStudyImagesList);
foreach (var sliderPictures in caseStudyImagesCollection)
{
<img src="@sliderPictures.Url"/>
}
}
Anyone else having this issue ...? Any help would be appreciated.
UPDATE ... I managed to find a related thread with both the "cause" and the "solution" ... thanks to Josh Bula and Jamie Pollack this has been resolved ... see below:
Here's my updated code block that WORKS (so you can see the applied edits):
@if (Model.Content.HasValue("sliderPictures"))
{
var caseStudyImagesCollection = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("sliderPictures");
foreach (var sliderPictures in caseStudyImagesCollection)
{
<img src="@sliderPictures.Url" style="width:300px;height:300px" />
}
}
Here's a link to the related thread that I found both the answer AND an explanation as to why this is happening in Umbraco v7.6:
Media Picker Dynamic foreach loop not working? (Umbraco v7.6)
I can't get even the most basic of examples running using the Media Picker "Dynamic" example supplied in umbraco.org's media picker documentation.
I keep getting this error:
System.Collections.Generic.List
I can get the "Typed" version to work without any issues, but only if the media picker does NOT allow multiple items to be checked. After a long and exhausting search I still cannot find a solution.
Here's a copy of the code I'm working with:
Anyone else having this issue ...? Any help would be appreciated.
-- Brett
UPDATE ... I managed to find a related thread with both the "cause" and the "solution" ... thanks to Josh Bula and Jamie Pollack this has been resolved ... see below:
Here's my updated code block that WORKS (so you can see the applied edits):
Here's a link to the related thread that I found both the answer AND an explanation as to why this is happening in Umbraco v7.6:
https://our.umbraco.org/forum/templates-partial-views-and-macros/85128-media-picker-in-76-rc-input-string-was-not-in-a-correct-format
The only thing they didn't do is include a sample code block with the solution applied (which is now listed above).
I hope this helps!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion