I want to allow an image to be null in an embedded content property but can't get the code right, I'm getting an error as if there is something in the image property when there is not, any help would be much appreciated.
var nuggets= @Model.caseStudies;
{
@foreach (var nugget in nuggets) { var nuggetHeader = nugget.caseStudyTitle.InnerText; @*var nuggetImage = @Model.MediaById(int.Parse(nugget.caseStudySmallImage.InnerText));*@ var nuggetContent = nugget.caseStudyShortDescription.InnerText; var nuggetLink = @Model.NodeById(@nugget.caseStudyLink.InnerText); <li> <a href="@nuggetLink.Url" title="Link to: @nuggetHeader"> <h3> @nuggetHeader </h3> @{ string nuggetImage = nugget.caseStudySmallImage; if (!string.IsNullOrEmpty(nuggetImage)) { int mediaID = int.Parse(nuggetImage); nuggetImage2 = Model.MediaById(mediaID).umbracoFile.ToString(); <img src="@nuggetImage"/> } } </a> </li>
Error when image is null in Embedded Content
I want to allow an image to be null in an embedded content property but can't get the code right, I'm getting an error as if there is something in the image property when there is not, any help would be much appreciated.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.