Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I wish to add a default image if no project image has been uploaded in my backend.
I have this piece of code:
@if(Model.Content.HasValue("@item.pictureOfTheProject")) { var featureImage = Umbraco.TypedMedia((int)item.pictureOfTheProject); <img class="img-thumbnail" src="@featureImage.GetCropUrl(200, 200)" alt="@item.titleOfTheProject" /> } else { var noImage = "http://www.don-zalmrol.be/media/1439/no-thumb.png"; <img class="img-thumbnail" src="@noImage.GetCropUrl(200, 200)" alt="No image" /> }
But now it's only showing me the replacement photo, instead of one uploaded image for a project and one for a project that has no image.
I'm testing this on my personal site: http://www.don-zalmrol.be/brewing/
Thanks!
If you are getting the properties of "item" then does your if not need to be
@if (item.HasValue("pictureOfTheProject"))
Your if is not correct, I think it should be:
@if(item.HasValue("pictureOfTheProject"))
All be damned!
Both of you are correct. Now it's working! Many thanks!
This will now also resolve the nullref error I get when nothing is added :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Show replacement image if no image has been found
Hi,
I wish to add a default image if no project image has been uploaded in my backend.
I have this piece of code:
But now it's only showing me the replacement photo, instead of one uploaded image for a project and one for a project that has no image.
I'm testing this on my personal site: http://www.don-zalmrol.be/brewing/
Thanks!
If you are getting the properties of "item" then does your if not need to be
Your if is not correct, I think it should be:
@if(item.HasValue("pictureOfTheProject"))
All be damned!
Both of you are correct. Now it's working! Many thanks!
This will now also resolve the nullref error I get when nothing is added :)
is working on a reply...