I'm hoping you can help me with some razor scripting. I have Umbraco 6.1.6 using the CWS Start" package that Warren Buckley created.
I am trying to retrieve an image crop using the default image cropper in Umbraco from a child node. The structure of the doc types being used are;
CWSUrlList = Parent Node CWSUrl = Child Node
Each CWSUrl node includes an image which is selected via DAMP and that I want to display on the parent node page (CWSUrlList).
Below is the code that is just about working. I say "just about" because since removing some of the @using / @inherits calls I initially was using, the image is no longer being pulled through.
The crop I am trying to establish is called "dampNewWide", and has been based on the DAMP sample pack. So the Doc Type CWSUrl includes a DAMP item called "dampNewWide".
I am trying to run the code below within an mvc template - basically CWS Start. The other properties such as date and price work correctly.
@foreach (var urlItem in Model.Content.Children.Where(x => x.IsVisible())) {
var urlDate = @Convert.ToDateTime(urlItem.GetProperty("itemDate").Value).Date.ToString("dd MMMM yyyy"); var price = urlItem.GetProperty("itemPrice").Value.ToString(); var image = urlItem.GetProperty("itemImage").Value; var mediaItem = Umbraco.TypedMedia(image); var mediaItemComplete = mediaItem.GetPropertyValue("umbracoFile"); <img src="@mediaItemComplete" alt="@mediaItem.GetPropertyValue("Name")"/>
Child Node with DAMP Media
Hello Umbraco Community.
I'm hoping you can help me with some razor scripting. I have Umbraco 6.1.6 using the CWS Start" package that Warren Buckley created.
I am trying to retrieve an image crop using the default image cropper in Umbraco from a child node. The structure of the doc types being used are;
CWSUrlList = Parent Node
CWSUrl = Child Node
Each CWSUrl node includes an image which is selected via DAMP and that I want to display on the parent node page (CWSUrlList).
Below is the code that is just about working. I say "just about" because since removing some of the @using / @inherits calls I initially was using, the image is no longer being pulled through.
The crop I am trying to establish is called "dampNewWide", and has been based on the DAMP sample pack. So the Doc Type CWSUrl includes a DAMP item called "dampNewWide".
I am trying to run the code below within an mvc template - basically CWS Start. The other properties such as date and price work correctly.
@foreach (var urlItem in Model.Content.Children.Where(x => x.IsVisible())) {
var urlDate = @Convert.ToDateTime(urlItem.GetProperty("itemDate").Value).Date.ToString("dd MMMM yyyy");
var price = urlItem.GetProperty("itemPrice").Value.ToString();
var image = urlItem.GetProperty("itemImage").Value;
var mediaItem = Umbraco.TypedMedia(image);
var mediaItemComplete = mediaItem.GetPropertyValue("umbracoFile");
<img src="@mediaItemComplete" alt="@mediaItem.GetPropertyValue("Name")"/>
<h3>@urlItem.Name</h3>
<p>Listing Date:@urlDate</p>
<p>Price:$@price</p>
}
Any help would be greatly appreciated.
is working on a reply...