When you use published content to access properties, the raw saved values in the database are run through an appropriate PropertyValueConverter to turn them into Models that make working with them easier in implementation scenarios, controllers/views etc.
Usually, you wouldn't use the ContentService in the front end of your site as it operates directly on the database, and is slow, but there isn't usually the need to convert the stored JSON into nice models for presentation, which is why you have the raw Json to play with :-(
ContentService IContent GetValue from MediaPicker3 from unpublished version
Hi I get image url from a saved content and not from the current published element, but I don't want to use JObject or JArray.
How I can retrieve values directly in models?
Thankyou for help
Damiano
Hi Damiano
When you use published content to access properties, the raw saved values in the database are run through an appropriate PropertyValueConverter to turn them into Models that make working with them easier in implementation scenarios, controllers/views etc.
Usually, you wouldn't use the ContentService in the front end of your site as it operates directly on the database, and is slow, but there isn't usually the need to convert the stored JSON into nice models for presentation, which is why you have the raw Json to play with :-(
The MediaPickerWithCropsValueConverter is here:
https://github.com/umbraco/Umbraco-CMS/blob/7b336c45f7cdfcc7e9cfd0f33bedd63c06333c1b/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/MediaPickerWithCropsValueConverter.cs#L78
I'm wondering if this would perhaps show a way to convert the JSON stored for the MediaPickerWithCrops into more familiar models?
regards
Marc
is working on a reply...