Return to doc.sitecore.com

Valid for Sitecore 5.3, 5.2
In the XSL how do I extract the reference link to the file?

Q:

In the XSL how do I extract the reference link to the file? 

For the 'Image' field i use sc:image and it returns a '~/media/Images/TopBanners/banner1.ashx' path. Which command do I use to extract a similar path? The only one I seem to be able to get is '/Files/CSS/styles_about' which isn't correct.

A:

The code sample below shows the way you can work with the file field in XSLT:

  <xsl:variable name="mediaItem" select="sc:fld('file',.)" />
  <xsl:variable name="mediaItemPath" select="concat('/sitecore/media library', $mediaItem)" />
  <img src="{sc:fld('path', sc:item($mediaItemPath, .))}"></img><br />