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'm beginning level for umbraco. I am trying to carry on a project that was already done and things are bad. I use umb // media / .. ads6a56fa5d6s .. to draw some pictures from another page. I read it elsewhere this solving:
// Your string which is retrieved from Archetype.
var imageString = "umb://media/c33bfe07a82b4df18a79db154139cb91";
// Get the guid from this string.
var imageGuidUdi = GuidUdi.Parse(imageString);
// Get the ID of the node!
var imageNodeId = ApplicationContext.Current.Services.EntityService.GetIdForKey(guidUdi.Guid, (UmbracoObjectTypes)Enum.Parse(typeof(UmbracoObjectTypes), guidUdi.EntityType, true));
// Finally, get the node.
var imageNode = Umbraco.TypedMedia(imageNodeId.Result);
But why am I getting an error for "guidUdi" here? How can I solve it.
I think you can pass the Guid into the TypeContent method, you certainly shouldn't ever need to use a management service for rendering.
var imageGuidUdi = GuidUdi.Parse(imageString).Guid;
var imageNode = Umbraco.TypedContent(imageGuidUdi);
Sorry, this is untested as I'm on the move right now.
it worked !!
I can’t thank you enough (:
No problem! As I said before if you ever find yourself using ApplicationContext.Current.Services for rendering content then something is wrong and there will be a different approach that you will need to find.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted