Copied to clipboard

Flag this post as spam?

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


  • Praj Devkota 1 post 21 karma points
    Feb 16, 2012 @ 03:54
    Praj Devkota
    0

    Use of umbraco.library:GetMedia to retrieve text field crashes umbraco

     

    Umbraco Version: 4.0.0 (Assembly version 1.0.3317.32692)

    ASP.net version: 2.0.50727

    Wndows & IIS Version: Windows server 2003 R2 SP2 / IIS7

    Stacktrace:

    Event Type:         Error

    Event Source:     .NET Runtime 2.0 Error Reporting

    Event Category: None

    Event ID:              1000

    Date:                    14/02/2012

    Time:                    5:42:49 PM

    User:                    N/A

    Computer:           XXXX

    Description:

    Faulting application w3wp.exe, version 6.0.3790.3959, stamp 45d6968e, faulting module kernel32.dll, version 5.2.3790.4062, stamp 46264680, debug? 0, fault address 0x0000bee7.

     

    Detailed Description:

    The code in red color causing the crash.  Applicaiton pool recycle is reqruied to bring back the server.  Please help.


                                   <xsl:variable name="CoverImg" select="umbraco.library:GetMedia(@id, 'false')/data [@alias='CoverImage']"/>

                                  <xsl:variable name="Note" select="umbraco.library:GetMedia(@id, 'false')/data [@alias='ImgNote']"/>

     

                                  <xsl:choose>

                                  <xsl:when test="$CoverImg != ''">

                                                                <li>

                                                                <a class="hoverImg" href="{umbraco.library:GetMedia(@id, 'false')/data [@alias = 'umbracoFile']}" target="_blank"><xsl:value-of select="@nodeName"/>

                                                                <span><img alt="" src="{umbraco.library:GetMedia(@id, 'false')/data [@alias='CoverImage']}" /><br/>

                                                                               <xsl:if test="$Note != ''">

                                                                                              <xsl:value-of select="$Note" />

                                                                               </xsl:if>

                                                            </span>

                                                                </a>

                                                                </li>

                                  </xsl:when>

     

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Feb 16, 2012 @ 14:16
    Chriztian Steinmeier
    1

    Hi Praj,

    Try this instead - it's not easy to see where your code goes wrong, but it's doing a couple of not so good things (e.g., calling GetMedia() several times for the same item) - this will make sure only to fetch the media once, and to reference the data from the cached item instead:

    <!-- Only fetch the media item once -->
    <xsl:variable name="mediaNode" select="umbraco.library:GetMedia(@id, false())" />
    <xsl:if test="not($mediaNode/error)">
    
        <xsl:variable name="CoverImg" select="$mediaNode/data[@alias = 'CoverImage']" />
        <xsl:variable name="Note" select="$mediaNode/data[@alias = 'ImgNote']" />
        <xsl:choose>
            <xsl:when test="normalize-space($CoverImg)">
                <li>
                    <a class="hoverImg" href="{$mediaNode/data[@alias = 'umbracoFile']}" target="_blank"><xsl:value-of select="@nodeName" />
                        <span>
                            <img alt="" src="{$CoverImg}" /><br/>
                            <xsl:if test="normalize-space($Note)">
                                <xsl:value-of select="$Note" />
                            </xsl:if>
                        </span>
                    </a>
                </li>
            </xsl:when>
        </xsl:choose>
    </xsl:if>

     

    Please be sure to use false() instead of 'false' - in XSLT 'false' is just a string, which will be converted to the boolean true for the C# extension. 

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft