x First time here? Check out the FAQ

GetMedia

    The method is used to get information of files in the media library - such as filename, size, height, width.

    Parameters

    GetMedia(int MediaId, bool Deep);

      Integer   MediaId 
    Boolean   Deep

    Return value

    The method returns a XPathNodeIterator with the information of selected file.

    Usage

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

    Getting the url of a media file with hardcoded ID

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

    Getting the url of a media file using a mediaPicker

    <xsl:value-of select="umbraco.library:GetMedia($currentPage/data[@alias='yourProperty'], 0)/data [@alias = 'umbracoFile']"/>

    How to render an image from XSLT

    Assuming the property alias is 'bannerImage' then:

     <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/data[@alias='bannerImage'], 0)/data" />

     <xsl:if test="$media">
      <xsl:variable name="url" select="$media [@alias = 'umbracoFile']" />
      <xsl:variable name="width" select="$media [@alias = 'umbracoWidth']" />
      <xsl:variable name="height" select="$media [@alias = 'umbracoHeight']" />
      <img src="{$url}" width="{$width}" height="{$height}" />
     </xsl:if>

    In the new syntax (Umbraco 4.5.1 onwards) this has changed to:

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/imageAlias, 0)" />

    <xsl:if test="$media">
      <img src="{$media/umbracoFile}" alt="{$media/altText}" />
    </xsl:if>

    If you are using Umbraco 4.5.0, there was a minor bug with GetMedia where you need to reference the root element (nodeTypeAlias). i.e. "$media/Image/umbracoFile".  That bug was fixed in Umbraco 4.5.1.

     

    PLEASE NOTE: This has been copied directly from the old Umbraco Wiki. Kudos to the original poster.