Copied to clipboard

Flag this post as spam?

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


  • Francielle 65 posts 279 karma points
    Aug 21, 2017 @ 12:52
    Francielle
    0

    Problem with MediaPicker in Umbraco 7.6.5. No definition for Url

    I have a document node which has a property so user can set the category of the document. This property is a content picker for the node of type category.

    Node category has the following properties: Name, Image and Color. Depending on the category selected, the font color changes, name of the category is displayed and the image as well.

    I am having some trouble displaying the image, which is a Media Picker.

    This is my code:

    //Code to get the category

    var category = Umbraco.TypedContent(@item.GetPropertyValue<int>("category"));
    dynamic node = new umbraco.MacroEngines.DynamicNode(category.Id);
    

    To get the image, I was doing the following:

      var categoryImage = node.GetPropertyValue<IPublishedContent>("categoryImage");
    

    The code above returns the following: "umb://media/48d7d9590b7649a39dd60ab4658c152f"

    To render the image I tried this:

    @categoryImage.Url and @Umbraco.Media(categoryImage).Url

    But it returns that string does not contain a definition for Url. Can someone help me?

  • Neil Hodges 338 posts 987 karma points
    Aug 25, 2017 @ 14:52
    Neil Hodges
    0

    Hi

    Would it not just be:

    var category = Umbraco.TypedContent(@item.GetPropertyValue<int>("category"));
    
    var categoryImage = category.GetPropertyValue<IPublishedContent>("categoryImage");
    

    then this should return the URL:

    @categoryImage.Url
    
Please Sign in or register to post replies

Write your reply to:

Draft