Copied to clipboard

Flag this post as spam?

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


  • Brenton Mumford 19 posts 40 karma points
    Mar 22, 2011 @ 23:09
    Brenton Mumford
    0

    Display GetMedia Content in Template

    So, I'm trying to display the location of some file - .doc or .xls, maybe even .html - that's been uploaded to somewhere in Media and linked to using the Media Picker.  So, I've got this line of code:

    <umbraco:Item field='documentationLocation' xslt='umbraco.library:GetMedia({0},true())' xsltDisableEscaping='true' runat='server' />

    And what that gives me is close, but not quite:

    /media/8117-Specifications_v1.docdoc1294336

    The extra doc is the file type and the 1294336 is the file size.  That's nice to know, but I'd prefer if I could display just the location so I can place that line inside an href and have someone right-click and download the file.

    What I don't understand is that I can do this sort of thing with the Content Picker and NiceUrl:

    <umbraco:Item field='documentationPage' xslt='umbraco.library:NiceUrl({0})' runat='server'></umbraco:Item>

    So, any ideas would be appreciated.  I didn't see this exact thing anywhere in the forums.  We're running 4.6.

  • Pasang Tamang 258 posts 458 karma points
    Mar 23, 2011 @ 05:07
    Pasang Tamang
    1

    Hi Brenton

    I found some part of code is missing in your code. Please try this 

    <a href="<umbraco:Item field='documentationLocation' xslt='umbraco.library:GetMedia({0},true())/umbracoFile' xsltDisableEscaping='true' runat='server' />">My Media</a>
  • Brenton Mumford 19 posts 40 karma points
    Mar 23, 2011 @ 14:49
    Brenton Mumford
    0

    That's it!  So, I presume by extension that if you were so inclined, you could aslo get the file size and/or file type?  Because now that I know that, I'm certain to want to.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 28, 2011 @ 19:54
    Kim Andersen
    0

    Hi Brenton

    Yeah, you can grab all of the properties from the media node, just lige the umbracoFile. Just do it the same way, but change the alias'es on the fields. Should work like a charm :)

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft