title: Get file size from media folder in Umbraco using XSLT
body: <p>Below is a part of my Umbraco xslt where I am outputting a PDF file link and the size of the file. The problem I am having, is targetting the size attribute of the media file. The size attribute has the alias of umbracoBytes.</p>
  
  <p>I just seem to not be able to target this.</p>
  
  <p>So all I am outputting at the moment is the link to open the PDF, but not the file size.</p>
  
  <p>Anyone who can help would be greatly appreciated. Thanks.</p>
  
  <pre><code>&lt;td&gt;
        &lt;xsl:if test="document= ''"&gt;
          &lt;xsl:value-of select="@nodeName"/&gt;
        &lt;/xsl:if&gt;
        &lt;xsl:if test="document != ''"&gt;
        &lt;a target="_blank"&gt;   
          &lt;xsl:attribute name="href"&gt;
            &lt;xsl:value-of select="umbraco.library:GetMedia(document, 'false')/umbracoFile"/&gt;
          &lt;/xsl:attribute&gt;
          &lt;xsl:value-of select="@nodeName"/&gt;       
          &lt;xsl:variable name="size" select="data [@alias = 'umbracoBytes']" /&gt;
            &lt;xsl:variable name="sizeAndSuffix"&gt;
                &lt;xsl:choose&gt;
                        &lt;xsl:when test="$size &amp;gt;= 1073741824"&gt;
                                &lt;xsl:value-of select="format-number($size div 1073741824,'#,###')"/&gt;
                                &lt;xsl:text&gt;GB&lt;/xsl:text&gt;
                        &lt;/xsl:when&gt;
                        &lt;xsl:when test="$size &amp;gt;= 1048576"&gt;
                                &lt;xsl:value-of select="format-number($size div 1048576,'#,###')"/&gt;
                                &lt;xsl:text&gt;MB&lt;/xsl:text&gt;
                        &lt;/xsl:when&gt;
                        &lt;xsl:when test="$size &amp;gt;= 1024"&gt;
                                &lt;xsl:value-of select="format-number($size div 1024,'#,###')"/&gt;
                                &lt;xsl:text&gt;KB&lt;/xsl:text&gt;
                        &lt;/xsl:when&gt;
                        &lt;xsl:when test="$size &amp;gt; 0 and $size &amp;lt; 1024"&gt;
                                &lt;xsl:value-of select="format-number($size div 0,'#,###')"/&gt;
                                &lt;xsl:text&gt;Bytes&lt;/xsl:text&gt;
                        &lt;/xsl:when&gt;
                        &lt;xsl:otherwise&gt;
                                &lt;xsl:text&gt;0 Bytes&lt;/xsl:text&gt;
                        &lt;/xsl:otherwise&gt;
                &lt;/xsl:choose&gt;
          &lt;/xsl:variable&gt;
  
        &lt;/a&gt;
        &lt;/xsl:if&gt;
      &lt;/td&gt;
  </code></pre>