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
Hi all,
Can someone explain why am not getting an display when using Media Picker with alias "Slider" in razor.
@using umbraco.MacroEngines@{ var chosenMedia = Model.MediaById("slider"); if (chosenMedia.NodeTypeAlias == "Folder") { foreach (var img in chosenMedia.Children) { if (img.NodeTypeAlias == "Image") { <img src="@img.umbracoFile"/> } } } }
Hi Fuji,
Model.MediaById expects an integer representing the ID of the media, not a nodeTypeAlias.
Assuming your document has a media picker with the alias of slider that selects a folder? You could try:
var chosenMedia = Model.MediaById(Model.slider);
-Tom
Hi Tom,
I did try this out as well but no output. Am using a Media Picker with Alias "Slider".
var chosenMedia = Model.MediaById(Model.slider); if (chosenMedia.NodeTypeAlias == "Folder") { foreach (var img in chosenMedia.Children) { if (img.NodeTypeAlias == "Image") { <img src="@img.UmbracoFile" alt="@img.Name"/> } } }
Seems to work fine from here, you sure you're using the right aliases, have the right folder selected etc? Maybe try setting some breakpoints if using VS or otherwise output some info to make sure your checks are passing..
<p>slider: @Model.slider</p>
<p>chosenMedia.NodeTypeAlias: @chosenMedia.NodeTypeAlias</p>
<p>img.NodeTypeAlias: @img.NodeTypeAlias</p>
etc
Yes i works Tom, Looks like at some point the "Save and Publish" wasnt doing anything.
//fuji
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Media Picker with Razor not displaying Images
Hi all,
Can someone explain why am not getting an display when using Media Picker with alias "Slider" in razor.
Hi Fuji,
Model.MediaById expects an integer representing the ID of the media, not a nodeTypeAlias.
Assuming your document has a media picker with the alias of slider that selects a folder? You could try:
-Tom
Hi Tom,
I did try this out as well but no output. Am using a Media Picker with Alias "Slider".
Seems to work fine from here, you sure you're using the right aliases, have the right folder selected etc? Maybe try setting some breakpoints if using VS or otherwise output some info to make sure your checks are passing..
etc
-Tom
Yes i works Tom, Looks like at some point the "Save and Publish" wasnt doing anything.
//fuji
is working on a reply...