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,
I'm trying to get a collection af alle my images with a specific value in one of the properties:
model.memberid = int (the value is currect).
var currectImage = Umbraco.TypedMedia(1291).Children.Where(x => x != null && x.GetProperty("customCreatorId").Value.Equals(model.memberid));
it returns "Object reference not set to an instance of an object."
You can see the whole code below:
var currectImage = Umbraco.TypedMedia(1291).Children.Where(x => x != null && x.GetProperty("customCreatorId").Value.Equals(1288)); if (currectImage != null) { if (currectImage.Count() > 1) { var imageToDelete = currectImage.FirstOrDefault(); var deleteMedia = Services.MediaService.GetById(imageToDelete.Id); Services.MediaService.Delete(deleteMedia); } member.SetValue("image", currectImage.FirstOrDefault().Id); }
Hope someone can tell me why it fails.
It's probably the .Value in .GetProperty("customCreatorId").Value
.Value
.GetProperty("customCreatorId").Value
Is it possible that there is a child node with an empty customCreatorId?
You can try .GetPropertyValue<string>("customCreatorId")
.GetPropertyValue<string>("customCreatorId")
Hi Damiaan,
I feel so stupid, you were right, that one of the images needed a property value.
thanks !
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get custom property from image/media in Surface controller
Hello,
I'm trying to get a collection af alle my images with a specific value in one of the properties:
model.memberid = int (the value is currect).
it returns "Object reference not set to an instance of an object."
You can see the whole code below:
Hope someone can tell me why it fails.
It's probably the
.Value
in.GetProperty("customCreatorId").Value
Is it possible that there is a child node with an empty customCreatorId?
You can try
.GetPropertyValue<string>("customCreatorId")
Hi Damiaan,
I feel so stupid, you were right, that one of the images needed a property value.
thanks !
is working on a reply...