Copied to clipboard

Flag this post as spam?

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


  • manwood 87 posts 109 karma points
    Apr 02, 2010 @ 16:56
    manwood
    0

    How do I get just the filename segment of an umbraco media file?

    I can get the full path to a media file using

    umbraco.library:GetMedia(./data [@alias = 'downloadFile'], 0)/data [@alias = 'umbracoFile']

    which works and is good for the actual link, but i want to display just the filename - myfile.pdf

    rather than the full path media/3455/myfile.pdf

    How do i get just the filename segment?

     

    thanks

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 02, 2010 @ 19:12
    Tom Fulton
    0

    Here's an idea...probably not the cleanest way but it works.  Basically uses the Replace function to replace "/media/<nodeid>/" with nothing

     

    <xsl:value-of select="umbraco.library:Replace(umbraco.library:GetMedia(./data [@alias = 'slideImage'], 0)/data [@alias = 'umbracoFile'], concat('/media/', ./data[@alias = 'slideImage'],'/'),'')"/>

  • Paul Sterling 719 posts 1556 karma points MVP 9x admin c-trib
    Apr 02, 2010 @ 22:00
    Paul Sterling
    1

    You can also just use the node name:

    <xsl:value-of select="@nodeName" />

    Assuming you've named the node the same as your file.

    -Paul

  • Paul Blair 466 posts 731 karma points
    Apr 02, 2010 @ 22:39
    Paul Blair
    0

    in addition to Paul's suggestion I have also had to remove the extensions some times (which is added automatically if you use the multiple upload tool).

    I do this by:

        <xsl:variable name="extension">.<xsl:value-of select="./data[@alias='umbracoExtension']"/></xsl:variable>
        <xsl:variable name="theTitle" select="Exslt.ExsltStrings:replace(@nodeName, $extension, '')"/>

    Cheers

    Paul

  • Sean Dooley 289 posts 528 karma points
    Jun 08, 2011 @ 12:58
    Sean Dooley
    0

    I have used the following snippet to get the node name of an uploaded image in the Media section

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/image, 0)" />
    <img src="{$media/umbracoFile}" alt="{$media/@nodeName}"/>

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies