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
If you, in a Media Picker, pick an image and then deletes the image in the media section, the image id is still stored in the picker.
How do I check for this scenario in Razor ?
If I don't do anything the code will fail.
Just check for null when rendering an image.
You can check if the value of your media picker is null, like if (Model.MyMediaPicker == null) or if (Model.GetPropertyValue<IPublishedContent>("myMediaPicker") == null)
if (Model.MyMediaPicker == null)
if (Model.GetPropertyValue<IPublishedContent>("myMediaPicker") == null)
For rendering the image ie.
@if (Model.MyMediaPicker != null)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted