Outputting Path to Uploader Image on Document Type in Partial View
Hi all,
I'm trying to output an image on a partial view of a page, I seem to be able to get all the other properties. But when I try and get my property Image which is an Uploader nothing is coming back.
I've uploaded an image in the CMS fine. Are there any properties I need to access further??
Also is there any SDK or a place where I can get the class definitions and members of all the property classes?
@inherits RenderViewPage @using Umbraco.Cms.Web;
<ul> @foreach (var item in Model.ChildContent().OrderBy(x => x.AsDynamic().DisplayOrder)) { var dynamicItem = item.AsDynamic();
var image = dynamicItem.Image; var bodyText = dynamicItem.BodyText; var fromText = String.Format("{0}, {1}", dynamicItem.From, dynamicItem.Location);
if you are using Visual Studio then you can attach it to the process to be able to debug your razor script and use the "Immediate window" or simply just put <p>@image</p> above your image tag so you can see what is the value of the variable
I still can't get this to work, I deleted the image property and called one mainImage. I've output it and there's an empty string. Code for partial view is below:
@inherits RenderViewPage @using Umbraco.Cms.Web;
<ul> @foreach (var item in Model.ChildContent().OrderBy(x => x.AsDynamic().DisplayOrder)) { var dynamicItem = item.AsDynamic();
var mainImage = dynamicItem.MainImage; var bodyText = dynamicItem.BodyText; var fromText = String.Format("{0}, {1}", dynamicItem.From, dynamicItem.Location);
Outputting Path to Uploader Image on Document Type in Partial View
Hi all,
I'm trying to output an image on a partial view of a page, I seem to be able to get all the other properties. But when I try and get my property Image which is an Uploader nothing is coming back.
I've uploaded an image in the CMS fine. Are there any properties I need to access further??
Also is there any SDK or a place where I can get the class definitions and members of all the property classes?
@inherits RenderViewPage
@using Umbraco.Cms.Web;
<ul>
@foreach (var item in Model.ChildContent().OrderBy(x => x.AsDynamic().DisplayOrder))
{
var dynamicItem = item.AsDynamic();
var image = dynamicItem.Image;
var bodyText = dynamicItem.BodyText;
var fromText = String.Format("{0}, {1}", dynamicItem.From, dynamicItem.Location);
<li>
<img src="@image" alt="@fromText" />
@Html.Raw(bodyText)
<span>@fromText</span>
</li>
}
</ul>
Thanks in advance for any help,
Kevin
can you post what the "image" variable contains?
if you are using Visual Studio then you can attach it to the process to be able to debug your razor script and use the "Immediate window"
or
simply just put <p>@image</p> above your image tag so you can see what is the value of the variable
Hi,
I still can't get this to work, I deleted the image property and called one mainImage. I've output it and there's an empty string. Code for partial view is below:
@inherits RenderViewPage
@using Umbraco.Cms.Web;
<ul>
@foreach (var item in Model.ChildContent().OrderBy(x => x.AsDynamic().DisplayOrder))
{
var dynamicItem = item.AsDynamic();
var mainImage = dynamicItem.MainImage;
var bodyText = dynamicItem.BodyText;
var fromText = String.Format("{0}, {1}", dynamicItem.From, dynamicItem.Location);
<li>
<p>@mainImage</p>
@if (!String.IsNullOrEmpty(mainImage))
{
<img src="@mainImage" alt="@fromText" />
}
@Html.Raw(bodyText)
<span>@fromText</span>
</li>
}
</ul>
Ok I've figured this out, need to get the Media URL like this:
var mainImageUrl = Umbraco.GetMediaUrl(dynamicItem.Id, "mainImage");
Where mainImage is the name of my property.
is working on a reply...