Copied to clipboard

Flag this post as spam?

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


  • Christian Hansen 34 posts 204 karma points
    Sep 03, 2018 @ 09:34
    Christian Hansen
    0

    Get children by ID of multiple media picker

    Hello, i am trying to get the children of my multiple media picker. In backend i have picked a folder with 2 images. I can write "@Model.KarusselMappe" ("KarusselMappe" is my property name of the media picker) and it gives me an id: 1057 which is the id of the folder i have picked. But how can i get the children of this folder.

    I have tried with: var karusselMappeId = Model.KarusselMappe; foreach (var image in karusselMappeId.children)

    But i says: String does not contain a definition for children.

    Can someone help?

    Cant write .children?

  • Richard Eyres 98 posts 580 karma points
    Sep 03, 2018 @ 09:40
    Richard Eyres
    100

    I think you will need to get the TypedMedia item for the ID of the folder

    Umbraco.TypedMedia(karusselId)

    This will return an iPublishedContent item, which should then provide the children.

    The ID value is just an integer, so it wont know anything about Umbraco at that point.

    Hope that helps a little.

  • Christian Hansen 34 posts 204 karma points
    Sep 03, 2018 @ 09:44
    Christian Hansen
    0

    Hey Richard,

    THANKS, that works. I now have the ID of my images in my picked folder. Thanks a lot!

  • Richard Eyres 98 posts 580 karma points
    Sep 03, 2018 @ 09:45
    Richard Eyres
    0

    Glad that helped you out.

Please Sign in or register to post replies

Write your reply to:

Draft