Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello all!
I'm trying to get a macro parameter "test" that is a multiple media picker and iterate the images to the page.
@using Umbraco.Web.Models @inherits Umbraco.Web.Macros.PartialViewMacroPage @{ var mediaItems = Model.GetParameterValue<IEnumerable<IPublishedContent>>("test"); foreach (var item in mediaItems) { <p>@item.Url</p> } }
But I keep getting "System.NullReferenceException: Object reference not set to an instance of an object."
Am I looking at this the wrong way?
Old post but I like to have answers on them if people google and come across them...
The reason this did not work is because the item may not have any images selected and thus null.
You can either do a HasValue check or check that mediaItems is not null
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Object reference not set to an instance of an object, Multiple Media Picker in Macro Partial View
Hello all!
I'm trying to get a macro parameter "test" that is a multiple media picker and iterate the images to the page.
But I keep getting "System.NullReferenceException: Object reference not set to an instance of an object."
Am I looking at this the wrong way?
Old post but I like to have answers on them if people google and come across them...
The reason this did not work is because the item may not have any images selected and thus null.
You can either do a HasValue check or check that mediaItems is not null
is working on a reply...