I'm trying to get a property from an image but keep getting the error that the property cannot be null. The code below workes but I want to add an imageItem property called caption, which is just a text field. so that the user can change the link text I've tried @imageItem.GetPropertyValue("caption") but still get the same error. Can anyone help.
Thanks in advance
Natasha
<div class="carousel-caption">
@if(@imageItem.GetPropertyValue("text")!=null){
<p style="padding:10px 10px; background-color:rgba(73,68,68,.5);display:block; height:auto;max-width:550px;">
@imageItem.GetPropertyValue("text")<br/><br/>
@if(@imageItem.GetPropertyValue("linkPicker")!=null){
<!-- now convert to a Json object-->
string jsonStr = @imageItem.GetPropertyValue("linkPicker").ToString();
var jsonObj = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(jsonStr);
var link = Umbraco.TypedContent(Convert.ToInt16(@jsonObj["id"].ToString()));
<a href="@link.Url" style="color:#fff; font-weight:bold;">
Click here to find out more
</a>
}
</p>
}
</div>
Link text Image Item property
Hi All
I'm trying to get a property from an image but keep getting the error that the property cannot be null. The code below workes but I want to add an imageItem property called caption, which is just a text field. so that the user can change the link text I've tried @imageItem.GetPropertyValue("caption") but still get the same error. Can anyone help.
Thanks in advance Natasha
Hi Natasha,
What is imageItem? Is it node in Umbraco? Can you show your Umbraco node ? Can you make some republish all you site?
Thanks
Hi Alex,
imageItem is a media node(umbracoFile). I will try republishing the whole site and see what happens.
Best wishes Natasha
For anyone who has the same issue saving the media items again did the trick and I used
Best wishes Natasha
is working on a reply...