Copied to clipboard

Flag this post as spam?

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


  • Mikael Mørup 297 posts 326 karma points
    Sep 03, 2009 @ 09:10
    Mikael Mørup
    0

    How to get media name from API

    I have some media of type file, when they are uploaded they are given a name.

    How can i get that name with the API. (I don not mean the umbracoFile name)

    I have tried to do this:

     

    Dim m As New umbraco.cms.businesslogic.media.Media(nodeId)
    Dim name as string                      

    name = m.getProperty("nodeName").value.toString()

    I also tried
    name = m.getProperty("name").value.toString()

    and name = m.getProperty("text").value.toString() (because text is the name of the actual DB field)

    but none of the above properties seems to exist

    What am i doing wrong?

     

    thanks

    Mikael

  • Sebastiaan Janssen 5061 posts 15523 karma points MVP admin hq
    Sep 03, 2009 @ 09:22
    Sebastiaan Janssen
    0

    Try this:

    Media m = new umbraco.cms.businesslogic.media.Media(nodeId);
    name = m.text;

     

  • Mikael Mørup 297 posts 326 karma points
    Sep 03, 2009 @ 09:51
    Mikael Mørup
    0

    Yes that was exactly what i was looking for.

    Thanks

    Mikael

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 03, 2009 @ 10:27
    Dirk De Grave
    0

    Mikael,

    Some extra info: Only custom defined properties can be addressed using the getProperty() method as you've specified. (syntax: x.getProperty("propertyAlias").Value)

    All 'generic' properties are defined as properties on the object ifself

     

    Cheers,

    /Dirk

  • Mikael Mørup 297 posts 326 karma points
    Sep 03, 2009 @ 11:29
    Mikael Mørup
    0

    Thanks Dirk, that is starting to make sense to me now :-)

     

    Mikael

Please Sign in or register to post replies

Write your reply to:

Draft