Does your media item has a property with alias "umbracoFile" .. it is the property with the upload datatype (or you might have chosen to use image cropper).
Okay, but "slideImages" is the alias of your multiple media picker property in content section, right?
It picks some media items, so images (or image because it represent 1 media image item) and then inside the loop you can access the properties on the media item.. if you go to Settings --> Media Types --> Image just can see the properties similar to how it works with Document Types.
Does this give you any result?
@foreach (var image in imageCollection)
{
<img src="@image.GetPropertyValue("umbracoFile")" />
}
Display images from mediapicker
Hi all
Hope you can help with a newbee question, how do I display the images in a foreach loop?
I can retrive the name but can't display the images.
Hi Soren
Try:
in your loop!
Also, really helpful I found when getting to grips with Umbraco and available properties, is the cheat sheet, that Peter Gregory put together:
https://our.umbraco.org/FileDownload?id=8866
regards
marc
Thank you for the quick reply.
I got the cheat sheet and tried with .Url but get this error
"Cannot resolve a Url for a media item when there is no 'umbracoFile' property defined."
Hi Søren
Does your media item has a property with alias "umbracoFile" .. it is the property with the upload datatype (or you might have chosen to use image cropper).
If it has another alias you can use
/Bjarne
Hi Bjarne
I am using the "multiple media picker" with alias "sliderImages".
In developer tools it counts the right amount of images but no src:
Thank you for the help
Okay, but "slideImages" is the alias of your multiple media picker property in content section, right?
It picks some media items, so images (or image because it represent 1 media image item) and then inside the loop you can access the properties on the media item.. if you go to Settings --> Media Types --> Image just can see the properties similar to how it works with Document Types.
Does this give you any result?
/Bjarne
no result.
I can grab the Url.Name and Url.Id in the loop but Url returns nothing :(
I appreciate your help Bjarne!
I need to find a good tut on implement a slider in umbraco 7 :)
Okay, so I guess it is the Slider media items you pick and not the default Image media item?
Which properties does Media Types --> Slider have?
Ensure it has umbracoFile if your want to use .Url .. otherwise you should also be able to access the property with:
/Bjarne
Here is an example of similar to yours: https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/media-picker
Can't remember want .Url returns on media items or if it is a typo, because it exists on content nodes.
Could you try with .UmbracoFile?
https://our.umbraco.org/documentation/Getting-Started/Design/Rendering-Media/
is working on a reply...