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
I am starting a new site using Umbraco version 7.6.1 assembly: 1.0.6337.40631.
I'm using Archetype as I have in a dozen other sites. I am using @Html.RenderArchetypePartials(Model.Content.GetPropertyValue
I've tried casting the object to a number of different things with no luck.
If I put a MediaPicker on my Document Type directly, I can see that the data is stored the same, but the base property converters work correctly and the usual Umbraco.Field("photo") returns the Id.
Here's how the data is stored:
Doc Type Property: ImageTest: umb://media/48e3a7837af44134a93e8d90141ece74
Is there a way to retrieve this from an Archetype? Am I missing something simple?
Try to use this code:
var mediaItems = Model.GetValue<IEnumerable<IPublishedContent>>("photo");
"Umbraco.Core.Udi" is a type of unified ids that are using in Core with Property Value Converters for getting all data directly from entities.
Thank you, Alex.
I tried so many things, I'm not sure which one did it, but it all the sudden started returning the media id as expected. I reinstalled everything from nuget and i'm assuming that did it. Obviously one of the type converters wasn't working correctly for some reason.
But I do appreciate your reply!
You are welcome, Trent.
Ids or UDI settings defined in config option in umbracoSettings.config
Did you read breaking changes in 7.6 version? -
I had read that. And I will be looking out for those changes as I update my current sites. This site that I was struggling with was a brand new site and my first one that started with 7.6 Umbraco. I did notice in the definitions that the property editor name was MediaPicker2. I'm guessing that's the new one mentioned in the article.
I was used to Model.GetValue(xxx) returning the ID of the media. As I circled back to this yesterday, I finally started a new Document Type to start from scratch. I did finally get this to work as intended using your suggestion of using the generic to cast it to IPublishedContent. Model.GetValue
I am anxious to see how the upgrade works and affects some of my current sites. I guess that's my next task. But your help certainly got me over the hump on this one.
You are welcome, really enjoy talking with Umbraco developers. Ask more if something.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted