I'm trying to retrieve the image of a media picker proeprty on a simple umbraco page, but the property always returns null.
I've saved and published the page, and the value shows in backoffice.
I've found similar questions, but the answers to those was to get the typed content and use value
Here's some examples of how i try to retrieve the property value:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
var logourl = Model.Logo;//null
var node = (DefaultPage)Umbraco.Content(Model.Id);
var val = node.Value<IPublishedContent>("logo");//null
var v = Model.HasProperty("logo");//true
}
Retrieving values from Title and Theme works, so I assume i have the right Model instance.
I looked in the DB and confirmed there was a value for logo in the textvalue field: umb://media/75b82e019752477e826ce3426abb286a
the node had value.
I tried creating a new site from the same doctype, and adding the image again, and put in a title, and that works fine.
The specific instance must be broken, but i can't figure where or why, since the doctype itself seems to work fine.
I'm just going to delete the corrupt instance of the doctype, and work with the one that works, and see if the issue reappears.
I'm experiencing similar problems and have identified my issue being related to "Vary by culture". It seems of a property is not "vary by culture" enabled, it returns null. In most use cases when using Media Picker there will not be differences between culture.
Mediapicker property returns null
I'm trying to retrieve the image of a media picker proeprty on a simple umbraco page, but the property always returns null. I've saved and published the page, and the value shows in backoffice.
I've found similar questions, but the answers to those was to get the typed content and use value
Here's some examples of how i try to retrieve the property value:
Retrieving values from Title and Theme works, so I assume i have the right Model instance.
I think it should be like this (in case of Media Picker)
Tested with
and the result is still that val is null.
Probably, problem is here:
Check, if
node
is not nullHey,
You could try -
I looked in the DB and confirmed there was a value for logo in the textvalue field: umb://media/75b82e019752477e826ce3426abb286a
the node had value.
I tried creating a new site from the same doctype, and adding the image again, and put in a title, and that works fine.
The specific instance must be broken, but i can't figure where or why, since the doctype itself seems to work fine. I'm just going to delete the corrupt instance of the doctype, and work with the one that works, and see if the issue reappears.
I'm experiencing similar problems and have identified my issue being related to "Vary by culture". It seems of a property is not "vary by culture" enabled, it returns null. In most use cases when using Media Picker there will not be differences between culture.
Was your case also a multi culture project?
is working on a reply...