Copied to clipboard

Flag this post as spam?

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


  • Eric 27 posts 49 karma points
    Aug 03, 2010 @ 00:08
    Eric
    0

    GetMedia returns System.OverflowException: Value was either too large or too small for an Int32.

    I am running Umbraco 4.5.1, clean install.

    I cannot get the image to show up, I've tried everything... well except the correct way.  Here is what I have:

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/bannerImage, 'false')" />
    <xsl:if test="$media">
            <img src="{$media/Image/umbracoFile}" alt="{$media/Image/altText}" />
    </xsl:if>


    It throws that error even when I just asign it to the variable.

     

  • Sascha Wolter 615 posts 1101 karma points
    Aug 03, 2010 @ 01:05
    Sascha Wolter
    0

    Hi Eric,

    the error occurs usually when you provide a parameter for the GetMedia method that might not be an Int32. Please try:

    <xsl:if test="$currentPage/bannerImage &gt; 0">
      <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/bannerImage, 'false')" />
     
    <img src="{$media/Image/umbracoFile}" alt="{$media/Image/altText}" />
    </xsl:if>

    This should assure the Xslt parser that GetMedia gets a proper value.

    Hope that helps,

    Sascha

  • Ove Andersen 435 posts 1541 karma points c-trib
    Aug 03, 2010 @ 12:52
    Ove Andersen
    0

    You can also try this:

    <xsl:if test="string($currentPage/bannerImage)!=''">
        <
    xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/bannerImage, 'false')" />
        <img src="{$media/Image/umbracoFile}" alt="{$media/Image/altText}" />
    </xsl:if>
  • Eric 27 posts 49 karma points
    Aug 03, 2010 @ 12:54
    Eric
    0

    When I do a value of bannerImage, it brings back the path of the image, I didn't think it was supposed to do that

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 03, 2010 @ 13:00
    Matt Brailsford
    0

    Hey Eric,

    Are you using a media picker as the data type for bannerImage?

    Just on another note, you shouldn't need "Image" in your selectors either

    <xsl:if test="string-length($currentPage/bannerImage) &gt; 0">
      <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/bannerImage, 'false')" />
     
    <img src="{$media/umbracoFile}" alt="{$media/altText}" />
    </xsl:if>

    Matt

  • Eric 27 posts 49 karma points
    Aug 03, 2010 @ 13:44
    Eric
    0

    I am using the media picker.

    All the image stuff is in a foreach loop: <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc]">     

    Whenever I try to assign the umbraco.library.GetMedia($currentPage/bannerImage, 'false') to the media variable, it always throws that error.  No matter if i enlose it in if statements.

    also currentpage is declared at the top, but will not work right.

    Example:

    I can get an image this way: <img src="{bannerImage}" width="596" height="304px" />, but NOT this way <img src="{$currentPage/bannerImage}" width="596" height="304px" />

    Here is the complete xsl, it doesnt make sense to me why this works, but the all the examples I see show a different way to get the image

    <xsl:param name="currentPage"/>
    <xsl:variable name="source" select="/macro/source"/>
        
    <xsl:template match="/">
      
      <div id="siBannerRotator">
        <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc]">
            <div class="banner">
               <xsl:choose>
                 <xsl:when test="string(splashPage) != '0'">
                   <img src="{bannerImage}" width="596" height="304px" />
                    <xsl:if test="string-length(shownText) &gt; '1'">
                      <span class="text">Shown:<br /><xsl:value-of select="umbraco.library:StripHtml(shownText)"/></span>
                    </xsl:if>
                 </xsl:when>
                 <xsl:otherwise>
                    <xsl:variable name="Picked" select="umbraco.library:Split(Pages,',')" />
                    <xsl:for-each select="$Picked//value">
                      <xsl:variable name="PageID" select="current()" />
                        <xsl:if test="$currentPage/@id = $PageID">
                          <xsl:if test="bannerImage">
                            <img src="{bannerImage}" width="596" height="304px" />
                            <xsl:if test="string-length(shownText) &gt; '1'">
                              <span class="text">Shown:<br /><xsl:value-of select="umbraco.library:StripHtml(shownText)"/></span>
                            </xsl:if>
                          </xsl:if>
                        </xsl:if>
                    </xsl:for-each>
                  </xsl:otherwise>
              </xsl:choose>
          </div>
          </xsl:for-each>
      </div>

     

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 03, 2010 @ 13:52
    Matt Brailsford
    0

    Hey Eric,

    It looks as though $source is a media node itself (ie a media folder) in which case when you pull back the XML for that node, it's already pulling back the XML for the child media nodes. I think you only have to do the GetMedia call, if you are working direct with a media items ID, which as you are looping through media nodes, you don't need.

    I'm not 100% on my knowledge of the media XML, but that would make most sence to me.

    Matt

  • Eric 27 posts 49 karma points
    Aug 03, 2010 @ 14:11
    Eric
    0

    That would make sense if I was pointing it to a media folder, but its pointing to a node in the content tree that has these document types that have a media picker, and some text fields.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 03, 2010 @ 14:16
    Matt Brailsford
    0

    Ok, then that is weird. I'm not sure why it would work that way.

    What do you get if after your test for bannerImage you do the following:

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

    What is output in the textarea?

    Matt

  • Eric 27 posts 49 karma points
    Aug 03, 2010 @ 14:38
    Eric
    0

    I get:

    </Div>
    </div>

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 03, 2010 @ 14:46
    Matt Brailsford
    0

    Really? Ok, something didn't go right there at all. Did you add it inside your if statement?

    <xsl:if test="bannerImage">
    <textarea>
           
    <xsl:copy-of select="bannerImage" />
    </textarea>
    </xsl:if>

    It should show you the markup of the bannerImage element.

    I'm really not sure why it would give you the direct string though, unless it's a bug

    Matt

  • Eric 27 posts 49 karma points
    Aug 03, 2010 @ 14:52
    Eric
    0

    Idk there are so many weird things going on in here.  I try to get the NiceUrl of the home page, and it brings back nothing.  Then when I create a sitemap from the xsl templates and before I do ANYTHING, I hit save and get this error:  System.OverflowException: Value was either too large or too small for an Int32.

     

  • Eric 27 posts 49 karma points
    Aug 03, 2010 @ 15:00
    Eric
    0
    <xsl:if test="bannerImage">
      <textarea>
           
    <xsl:copy-of select="bannerImage" />
      </textarea>
    </xsl:if>

    Worked, and brought back the correct id, but I had to ad back in the currentPage
  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 03, 2010 @ 15:49
    Matt Brailsford
    0

    Only thing I could suggest, is try republishing all your site. Right click on your home page, choose publish, and tell it to republish all child pages too.

    Maybe the cache is just corrupt.

    Matt

  • Eric 27 posts 49 karma points
    Aug 03, 2010 @ 16:01
    Eric
    1

    I tried, still issues, so I just deleted all the pages and recreated them, that seems to be working so far, thanks for your help!

  • MartinB 411 posts 512 karma points
    Aug 27, 2010 @ 20:41
    MartinB
    0

    I just had the exact same problem.

    Republish didn't work, so i deleted all the pages and added them again. Voilá

    Kinda strange though?

    Umbraco 4.5.2

  • Tony Lorentzen 85 posts 174 karma points
    Oct 07, 2010 @ 06:44
    Tony Lorentzen
    0

    4.5.2 is extremely unreliable. Sad, really! I have spent WAY too much time trying to debug the 4.5+ releases only to find that I had to use older versions to get a reliable website up and running.

Please Sign in or register to post replies

Write your reply to:

Draft