[Solved] Custom Media Type not being output from M...
# help-with-umbraco
c
Umb 12.2.0 I have a custom MediaType which inherits from Image and has an additional colour picker. There is also a specific Media Folder that only accepts the new custom MediaType. In a docType, I have a Media Picker set to only accept the new custom MediaType and targetted at just the new Media Folder. All is well until I try to render the image in the Media Type from the Media Picker. In the following code Model.HeadStoneStyle is always null:-
Copy code
MediaWithCrops? headstoneImage = null;
    MediaWithCrops? headstonePickerSingle = Model.HeadStoneStyle;
    if (headstonePickerSingle is MediaWithCrops headstoneImageItem) {
        headstoneImage = headstoneImageItem;
    }
There are no errors showing in Rider or in logs. Any suggestions would be appreciated. Thanks.
j
Can you get access to it with
.Value(“headstoneStyle”)
and see what type it’s returning? Sometimes I do that to test when I’m getting unexpected behavior on properties.
c
Good call, but... ``var headstonePickerSingle = Model.Value("headStoneStyle")`` just gives me object:null 😦
j
Hmmmmm, that definitely leads me to believe maybe something is spelled wrong? Capitalization kills me personally
c
I've checked that more times than I care to mention, AND the IDE isn't giving a red squiggley underline, so all should be well in that regard.
m
When debugging does the raw value have data? (In the properties)
c
No, it's just null, there's nothing to have properties 😦
m
Model.Properties then find the style property
c
The test page is saved and published too.
m
The raw value is what's saved in the database.Value uses the property converter so trying to limit our options:)
That looks fairly sensible to me.
m
Suggests then the nucache for the media item is missing try re save it
If it can't find the media item the Value converter will return null in single mode
c
Just wondering if the fact I added a colour picker to the new mediaType has blown up the value converter.
Sorted! I just deleted the whole Temp folder and restarted. It's now working.
Just need to get the value of my new TextColour property out now, lol
j
Yay I’m glad you got it sorted!
3 Views