Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ali 5 posts 74 karma points
    Aug 06, 2017 @ 05:23
    Ali
    0

    need help with retrieving url from media picker

    Hello, here is my code:

     var categories = Model.Content.HasProperty("categoryList") && Model.Content.HasValue("categoryList") ?
                        Model.Content.GetPropertyValue<ArchetypeModel>("categoryList")
                        .Fieldsets.Where(x => x != null && x.Properties.Any())
                        .Select(fs => new
                        {
                            Subcategory = fs.GetValue<string>("subcategory"),
                            ProductList = fs.HasValue("productLink") ? 
                                    fs.GetValue<ArchetypeModel>("productLink")
                                            .Fieldsets.Where(x => x != null && x.Properties.Any())
                                            .Select(fs2 => new
                                            {
                                                Title = fs2.GetValue<string>("title"),
                                                SubTitle = fs2.GetValue<string>("subTitle"),
                                                Body = fs2.GetValue<string>("body"),
                                                InternalLink = Umbraco.Url(Umbraco.GetIdForUdi(Udi.Parse(fs2.GetValue<string>("internalLink")))),
                                                ExternalLink = fs2.GetValue<string>("externalLink"),
                                                Image = Umbraco.TypedMedia(fs2.GetValue<IPublishedContent>("image")),
                                                Url = fs2.GetValue<IPublishedContent>("image"),
                                                Url1 = fs2.GetValue<IPublishedContent>("image"),
    
                                            }) :
                                    null
                        }) :
                    null;
    

    I have tried every possible way to get the url of the media picker which has pick multiple items disabled. with the URL property selected about i get the id of the content, but i am not able to get the url using Umbraco.Media or (fs2.GetValue

  • Ali 5 posts 74 karma points
    Aug 07, 2017 @ 23:52
    Ali
    0

    So for some strange reason, Url1 was an IPublishedContentType but it would not print the url if i did Url1.Url so i wrote a helper class and passed Url1 as a parameter to my helper and in my helper i took the same passed parameter and returned as Url1.Url and that worked. I still cant figure out why it wouldnt access any of the IPublishedContent Type properties in Razor code.

Please Sign in or register to post replies

Write your reply to:

Draft