Media Picker in 7.6 RC - Input string was not in a correct format
Following the example in the documentation for the Media Picker, I have this code trying to retrieve and display multiple images uploaded to the page through the new Media Picker:
@if (Model.Content.HasValue("slideshowImages"))
{
var imagesList = Model.Content.GetPropertyValue<string>("slideshowImages").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
var imagesCollection = Umbraco.TypedMedia(imagesList).Where(x => x != null);
foreach (var imageItem in imagesCollection)
{
<div class="abnner_slider_img" style="background-image: url('@imageItem.Url');"> </div>
}
}
On the foreach line, it throws an "Input string was not in a correct format" error.
If also throws the same error if I try to get a count of the images by doing either imagesList.Count() or imagesCollection.Count()
Media Picker in 7.6 RC - Input string was not in a correct format
Following the example in the documentation for the Media Picker, I have this code trying to retrieve and display multiple images uploaded to the page through the new Media Picker:
On the foreach line, it throws an "Input string was not in a correct format" error.
If also throws the same error if I try to get a count of the images by doing either imagesList.Count() or imagesCollection.Count()
Has something changed for 7.6 that breaks this?
Hi Josh,
One of the improvements for v7.6 is the inclusion of the rather fantastic Core Property Value Converters community package into the core.
This means your slideshowImages can automatically be accessed as follows:
So there should be no need for Umbraco.TypedMedia call.
I hope this helps :)
Thanks,
Jamie
Thanks Jamie, that worked perfectly!
Fantastic :)
is working on a reply...