I am writing a Razor to pull all the images with the property "featuredImage" from within a nodes children, but I must not be calling them correctly, as the script won't load. What am I missing?
@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
var i = 0;
var newsRoot = Model.NodeById(5583); @* The ID of the starting node *@
var alumniCategory = newsRoot.Children.Where("Visible"); @* The node containing the children with the "featuredImage" property *@
<div class="slider">
@foreach (var item in alumniCategory ){
if ( item.Media("featuredImage").UmbracoFile != "" ){
<div class="slide" id="@i">
if ( item.isVideo != true) {
<a href="@item.imageLink"><img src="@item.Media("featuredImage").UmbracoFile" /></a>
} else {
<a class="youtube" href="@item.videoURL?modestBranding=0&showinfo=0&autohide=1&autoplay=1&rel=0&fs=0&controls=0">
<img src="/media/1030033/VideoOverlay.png" class="overlay" />
<img src="@item.Media("featuredImage").UmbracoFile" />
</a>
}
<div class="caption">@item.copy</div>
</div>
i++;
}
}
</div>
Actually, ignore my last comment. I don't think its the cause of your problem. You seem to be missing some @ characters to signal the start of some Razor scripts. Try the following...
Pulling Images from a Node
Hello,
I am writing a Razor to pull all the images with the property "featuredImage" from within a nodes children, but I must not be calling them correctly, as the script won't load. What am I missing?
I'm sure if its an issue but you seem to be using nested double quotes on two different lines. Try the following instead:
Actually, ignore my last comment. I don't think its the cause of your problem. You seem to be missing some @ characters to signal the start of some Razor scripts. Try the following...
Actually Dan, It was the syntax for pulling the Media items.
I was using src="'@item.Media("featuredImage").UmbracoFile' and needed to use src="@item.Media("featuredImage", "umbracoFile")".
Thanks for your suggestions though.
is working on a reply...