Problem with UmbracoHelper.TypedMedia under Umbraco 7.6
Hi,
I have an IIS cached model that uses list of content items including an image id. This model is correctly populated with the media id under 7.6 to use the new udi format.
var image = umbracoHelper.TypedMedia(Model.Items[i].ImageUrl);
So Model.Items[i].ImageUrl contains a string in the format of "umb://media/f0853da8502642afa39deaa7094c828a" as expected. However, TypedMedia throws the following exception:
TypedMedia doesn't work with new formats of IDs in Umbraco.
It will work in next version, but for now, you have to change your code or disable "Property Value Converters"
However, the other method is fine when your model is an Umbraco DataType and not fine when it's a C# class being passed in - such as a that within a LeBlender model.
The ability to find a media idem using a UDI is - just as it did on the old integer Id's is somewhat critical - do you have any idea when this will be implemented?
No, in the forum post you linked to it refers to using UmbracoHelper.TypedContent as the way forward. Using UmbracoHelper.TypedContent updating the TypedMedia call to TypedContent produces the original error.
I know this isn't you Alex but this breaking change wasn't in the release notes for 7.6 - Umbraco can't just go about releasing updates that then don't work with well used functions that people have built into their sites. At least - not without telling them!
Having an absolute nightmare today with Umbraco 7.6 - so far its a very poor release.
Personally saying its in the next release isnt an answer, useful functionality that was working perfectly has been unnecessarily removed) a lot of developers will be struggling with content queries not working...
Problem with UmbracoHelper.TypedMedia under Umbraco 7.6
Hi,
I have an IIS cached model that uses list of content items including an image id. This model is correctly populated with the media id under 7.6 to use the new udi format.
So Model.Items[i].ImageUrl contains a string in the format of "umb://media/f0853da8502642afa39deaa7094c828a" as expected. However, TypedMedia throws the following exception:
Any ideas would be much appreciated.
Thanks
Simon
Hi Simon
TypedMedia doesn't work with new formats of IDs in Umbraco. It will work in next version, but for now, you have to change your code or disable "Property Value Converters"
Try this code:
Be aware that this code makes one more call to the database, so it's not the best practice.
Thanks,
Alex
Hi Alex,
Sorry but as TypedMedia is fairly key - why did the Umbraco team release 7.6 without this support?
If I don't want to make calls to the database what;s the best solution? You've already said what you've provided isn't best practice - what is?
Thanks
Simon
The best practice is to use "Property Value Converters" like:
What's "items"? The string media id such as "umb://media/f0853da8502642afa39deaa7094c828a"
Also, I can't find any reference to a ToPublishedContent() function for Udi.Parse - where did you find this?
"items" is just example of property alias in your content.
For "ToPublishedContent()", add please reference to "Umbraco.Web.Extensions"
OK - found the UDI ToPublishedContent thanks
However, the other method is fine when your model is an Umbraco DataType and not fine when it's a C# class being passed in - such as a that within a LeBlender model.
The ability to find a media idem using a UDI is - just as it did on the old integer Id's is somewhat critical - do you have any idea when this will be implemented?
Simon, guys told that pull request is already there and it will be in nearest release - https://our.umbraco.org/forum/templates-partial-views-and-macros/85768-new-content-picker-as-macro-parameter-v761#comment-272532
Unfortunately,
UmbracoHelper.TypedContent()
still returns the original error about:Did you mean
ToPublishedContent()
?No, in the forum post you linked to it refers to using UmbracoHelper.TypedContent as the way forward. Using UmbracoHelper.TypedContent updating the TypedMedia call to TypedContent produces the original error.
It will work in next releases. For now, we have to use 'ToPublishedContent()' or old pickers.
OK. Thanks for the help - will keep an eye out for the update.
Cheers
Simon
You are welcome, Simon. Have a great day!
Cheers
Alex
I know this isn't you Alex but this breaking change wasn't in the release notes for 7.6 - Umbraco can't just go about releasing updates that then don't work with well used functions that people have built into their sites. At least - not without telling them!
Did you upgrade some old solution to 7.6?
Simon, as I know there are a lot of breaking changes in 7.6 release.
List of breaking changes here - https://our.umbraco.org/documentation/Getting-Started/Setup/Upgrading/760-breaking-changes
Also some warning on the release page:
Yes, read all that - no where does it say that the built in UmbracoHelper.TypedMedia function doesn't support looking up using the UID.
Given this is an Umbraco provided/supported function - it's a bit poor it now doesn't work.
As for updating from "some old solution" - it was from the last version of 7.5.?? can't remember the last version
Simon, youre not alone.
Having an absolute nightmare today with Umbraco 7.6 - so far its a very poor release.
Personally saying its in the next release isnt an answer, useful functionality that was working perfectly has been unnecessarily removed) a lot of developers will be struggling with content queries not working...
Good!
Sorry - but half-done updates like this destroy Umbraco's reputation and mean updating production sites becomes a lottery.
Fortunately, this wasn't a production site but can you imagine???
is working on a reply...