I think the problem here is your use of .Content, which is no longer required when retrieving model properties (there's more on this here).
Have a try using the following:
var image = Model.Value<IPublishedContent>("image");
Alternatively, if you want to render something when the image returns null, use something like:
var image = Model.Value<IPublishedContent>("image") == null ? "http://via.placeholder.com/1280x720" : Model.Value<IPublishedContent>("image").Url;
There's another post here which may also be relevant - as it refers to clearing your cache - but I don't think that's the issue with your particular example.
Image always return null
Hi, I am using Umbraco 8.0.1 to get the image
hasValue returns true if there is a media item in the content page but the image value returns null data.
Thanks
What happens if you reload the NuCache? Are they visible after the reload?
Yes it is, but image will be null after few page loads
@Frans de Jong, I had the same issue and it got solved by clearing NuCache.
I think the problem here is your use of
.Content
, which is no longer required when retrieving model properties (there's more on this here).Have a try using the following:
Alternatively, if you want to render something when the image returns null, use something like:
There's another post here which may also be relevant - as it refers to clearing your cache - but I don't think that's the issue with your particular example.
Vishnu, peace be upon those who follow guidance.
This is how I displayed the image in a similar version
8.0.1
About the use of
Model.Content
or onlyModel
that was mentioned in @Shannon's slides.Thanks for sharing the document, it is very helpful
I suggest the selection of answer in case you found it which may help other later and to avoid having many posts without solution.
is working on a reply...