Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Mar 01, 2012 @ 09:09
    Fuji Kusaka
    0

    Display Media Item in Razor

    Hi Folks,

    How do i access a media section with razor like you would do in XSLT with Type mediaCurrent and get to display each item?

    Am trying to get the same results as i would be getting from my current XSLT.

    <xsl:variable name="mediaFolder" select="/macro/Docs"/>
    <xsl:if test="$mediaFolder">
        <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($mediaFolder/*/@id, true())"/>
        
        <xsl:for-each select="$mediaItems/File">
          <xsl:variable name="fileSize" select="umbracoBytes"/>
        <li>
          <a href="{umbracoFile}" target='_blank'>
              <xsl:value-of select="@nodeName"/>
          </a>&nbsp; -      
          <xsl:choose>
              <xsl:when test="$fileSize &gt;= 1048576">
                <xsl:value-of select="round($fileSize div 1048576)"/> MB              
              </xsl:when>
              <xsl:when test="$fileSize &gt;= 1024">
                <xsl:value-of select="round($fileSize div 1024)"/> KB            
              </xsl:when>
            <xsl:otherwise>
                 <xsl:text>0 Bytes</xsl:text>
            </xsl:otherwise>
        </xsl:choose>        
        </li>
        </xsl:for-each>
        
      </xsl:if>

     

Please Sign in or register to post replies

Write your reply to:

Draft