Copied to clipboard

Flag this post as spam?

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


  • ad de Vos 25 posts 46 karma points
    Feb 25, 2011 @ 14:18
    ad de Vos
    0

    getMedia, Value was either too large or too small for an Int32.

    Hi, I know there are a few topics about this, but the solutions are not working for me.

    I have a documenttype with an upload field.

    I have a XSLT script to display newsitems with image. When i do not have an image then all works fine, when i upload an image i get the error above. It´s failing on the code below:

     

       <xsl:choose>
                  <xsl:when test="current()/newsImage != ''">
      <xsl:if test="string-length(current()/newsImage) &gt; 0">  
      <xsl:variable name="media" select="umbraco.library:GetMedia(current()/bannerImage, 'false')" />  
         
                        <img src="{$media/umbracoFile}" alt="klik hier voor het nieuwsbericht" width="84" border="0"/>
    </xsl:if>
                      </xsl:when>
        <xsl:otherwise>
       <img src="/media/6468/empty.png" alt=""  width="84" border="0"/>
      </xsl:otherwise>
     </xsl:choose>

    Does sombody can help me with this.?

    Thank you. Kind regards,

    Ad

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 25, 2011 @ 14:27
    Tom Fulton
    0

    Hi,

    To avoid this error you typically test to see if the media picker property is empty.  It looks like you are doing that for newsImage but not for bannerImage?  Are you maybe mixing up the two names?

    Try..

      <xsl:choose>
        <xsl:when test="current()/bannerImage != ''">
            <xsl:variable name="media" select="umbraco.library:GetMedia(current()/bannerImage, 'false')" /> 
            <img src="{$media/umbracoFile}" alt="klik hier voor het nieuwsbericht" width="84" border="0"/>
        </xsl:when>
        <xsl:otherwise>
            <img src="/media/6468/empty.png" alt=""  width="84" border="0"/>
        </xsl:otherwise>
      </xsl:choose>

    Thanks,
    Tom

  • ad de Vos 25 posts 46 karma points
    Feb 25, 2011 @ 14:35
    ad de Vos
    0

    Thank you. I had pasted a solution but did not alter the names... but when i change the names it still wont work...

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 25, 2011 @ 14:40
    Tom Fulton
    0

    Hi,

    Are you still getting the error or is the image just not showing?

    Is the correct property bannerImage or newsImage?

    Is this code running inside a for-each loop?

    -Tom

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 26, 2011 @ 10:00
    Kim Andersen
    2

    Hi Ad

    If you are using a upload data type, then you shall not use the GetMedia-extension. The upload data type returns the path to the image directly to you, so that could be a reason to why the extension fails.

    /Kim A

  • ad de Vos 25 posts 46 karma points
    Feb 28, 2011 @ 11:55
    ad de Vos
    0

    Thank you, that was it.. just referenced the field and it worked like a charm... Got a lot to learn...

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 28, 2011 @ 16:11
    Kim Andersen
    0

    Great to hear that you got things worked out Ad.

    Sometimes it can be a good idea to print out the currentPage to see how the XML looks. You can do this like this:

    <textarea>
    <xsl:copy-of select="$currentPage" />
    </textarea>

    /Kim A

  • ad de Vos 25 posts 46 karma points
    Feb 28, 2011 @ 16:14
    ad de Vos
    0

    Great Tip! tnx

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 28, 2011 @ 16:17
    Kim Andersen
    0

    Yeah, it gives you a good idea on what to do with the different data.

    For this purpose you could maybe also try out the XML Dump package from Chriztian Steinmeier. But the textarea-trick does a great job as well :)

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft