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
I have a media picker with multiple images in there.
I have a surface controller. I want to get a list of the images from the property.
I have tried many ways but cannot do this. The only way it works is if I type a media ID in like this:
var logo = Umbraco.TypedMedia(1139);
This is not obviously a good way as i have multiple ID's.
I have tried this:
var galleryPage = Umbraco.Content(1143); var images = galleryPage.TypedMedia(galleryPage.Content.GetPropertyValue("galleryImages"));
but i get nothing
can someone please point me in the right direction.
Thanks
What version of umbraco are you using? :)
The latter versions have property value converters, where you can just ask for a list of publishedcontent like this:
var images = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("galleryImages")
with modelsbuilder it's even more simple:
var images = Model.Content.GalleryImages;
Thanks for the reply.
Yes but that is in the razor view isnt it?
I am doing this in a surfacecontroller..would it also work in their..if so what would "Model" be in a Controller.
that's just c# code.
Of course you may not have a model with content, but as long as you have the content, you should be able to use one of the methods described :)
sorry been a while, had this project on hold. Just like to add the above solution does not work. Still looking for a solution will post if i find one. Thanks
For anybody else looking for a solution this thread is a good read:
UID media urls
There are a few good threads on how to convert the UID to a proper media url or get the whole media object via the UID.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Getting ID from media picker
I have a media picker with multiple images in there.
I have a surface controller. I want to get a list of the images from the property.
I have tried many ways but cannot do this. The only way it works is if I type a media ID in like this:
This is not obviously a good way as i have multiple ID's.
I have tried this:
but i get nothing
can someone please point me in the right direction.
Thanks
What version of umbraco are you using? :)
The latter versions have property value converters, where you can just ask for a list of publishedcontent like this:
with modelsbuilder it's even more simple:
Thanks for the reply.
Yes but that is in the razor view isnt it?
I am doing this in a surfacecontroller..would it also work in their..if so what would "Model" be in a Controller.
that's just c# code.
Of course you may not have a model with content, but as long as you have the content, you should be able to use one of the methods described :)
sorry been a while, had this project on hold. Just like to add the above solution does not work. Still looking for a solution will post if i find one. Thanks
For anybody else looking for a solution this thread is a good read:
UID media urls
There are a few good threads on how to convert the UID to a proper media url or get the whole media object via the UID.
is working on a reply...