Copied to clipboard

Flag this post as spam?

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


  • Rachel Skuse 88 posts 118 karma points
    Sep 26, 2011 @ 12:29
    Rachel Skuse
    0

    GetMedia Error - Value was either too large or too small for an Int32

    Hi,

    I know this crops up in the forum quite a lot and I have read through various posts to try and resolve it but I'm just having no luck!

    Here is my code...

      <xsl:variable name="media" select="umbraco.library:GetMedia(./data[@alias='itemContentImage'], 0)/data" />
      <xsl:if test="$media > 0">
        <img src="{$media/umbracoFile}" />
      </xsl:if>

    but I just keep getting an error.

    Can anyone tell me where I'm going wrong?

    Thanks,

    Rachel

     

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Sep 26, 2011 @ 12:38
    Peter Dijksterhuis
    0

    Rachel,

    try this:

    <xsl:iftest="./data[@alias='itemContentImage'] != ''">
    <imgsrc="{umbraco.library:GetMedia(./data[@alias='itemContentImage'], 0)/umbracoFile}"/>
    </xsl:if>

    Peter

     

  • Rachel Skuse 88 posts 118 karma points
    Sep 26, 2011 @ 12:41
    Rachel Skuse
    0

    Hi Peter,

    I'm still getting the same error :(

    Rachel

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Sep 26, 2011 @ 12:43
    Peter Dijksterhuis
    0

    What is displayed when you do a xsl:value-of select="./data[@alias='itemContentImage']" ?

  • Rachel Skuse 88 posts 118 karma points
    Sep 26, 2011 @ 12:47
    Rachel Skuse
    0

    When using the visualizer It says 'The XSLT didn't generate any output'

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Sep 26, 2011 @ 12:51
    Peter Dijksterhuis
    0

    can you post your entire xslt?

  • Rachel Skuse 88 posts 118 karma points
    Sep 26, 2011 @ 12:57
    Rachel Skuse
    0

    Here you go...

    Thank you for looking :)

    <xsl:variable name="acPage" select="umbraco.library:GetXmlNodeById(5105)" />
    <!-- start writing XSLT -->
      <ul id="accordion">
        <xsl:for-each select="$acPage/node [@nodeTypeAlias='AccordianItem']">
          <li class="acItemTitle">
            <a href="#" class="acItemTitleA">
              <span class="acItemSpan"><xsl:value-of select="@nodeName" /></span>
              <span class="acItemTitleASpan">
                Read more
              </span>
              <span class="clear"><xsl:comment>1</xsl:comment></span>
            </a>
            <div class="acItemContent">
        <xsl:if test="./data[@alias='itemContentImage'] != ''">
            <img src="{umbraco.library:GetMedia(./data[@alias='itemContentImage'], 0)/umbracoFile}"/>
        </xsl:if>
        <xsl:value-of select="./data [@alias='itemContent']" />
        </div>
            <div class="clear"><xsl:comment>1</xsl:comment></div>
          </li>
        </xsl:for-each>
      </ul>

     

     

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Sep 26, 2011 @ 13:16
    Peter Dijksterhuis
    0

    Hm, if I create a new xslt and save this piece, I dont get an error. You do get an error when you save the xslt or when you view the page where the macro is on?

     

  • Rachel Skuse 88 posts 118 karma points
    Sep 26, 2011 @ 13:24
    Rachel Skuse
    0

    I get an error when using the visualizer (System.OverflowException: Value was either too large or too small for an Int32) and when I view the page it gives an error... 'Error parsing XSLT file: \xslt\AccordianListItems.xslt'


    I have just created a new xslt file and added the code but I'm getting the same errors.

    If I replace

    <xsl:if test="./data[@alias='itemContentImage'] != ''">

    with

    <xsl:if test="./data[@alias='itemContentImage'] > 0 ''">

    I no longer get an error but there is also no output for itemContentImage (but I do get output for itemContent)

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Sep 26, 2011 @ 13:34
    Peter Dijksterhuis
    0

    Ah, I probably can save just fine because I didn't have a property called itemContentImage.

    What type of property is that, is it a media-picker or an upload-field?

  • Rachel Skuse 88 posts 118 karma points
    Sep 26, 2011 @ 13:36
    Rachel Skuse
    0

    It's an upload field - does that make a difference? Should I be using a media picker?

    Thanks

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Sep 26, 2011 @ 13:44
    Peter Dijksterhuis
    1

    Yes, that makes a difference, for an upload-field you don't have to use the GetMedia.

    I'm not sure about the right syntax here, but if you try this:

    <textarea><xsl:copy-of select="./data[@alias='itemContentImage']"/></textarea>

    you then should get an idea what is in it and how you can output it.

    Peter

  • Rachel Skuse 88 posts 118 karma points
    Sep 26, 2011 @ 13:52
    Rachel Skuse
    0

    Ah, I see!

    The textarea is outputting...

    <data alias="itemContentImage">/media/764214/history.jpg</data>

    ??

    One other thing that I haven't seen before... itemContent (which is RichText Editor) is also outputting the html tags - how can I prevent that?

    Thanks.

     

  • Rachel Skuse 88 posts 118 karma points
    Sep 26, 2011 @ 14:00
    Rachel Skuse
    0

    Thank you for all your help Peter.

    I'm now using the following XSLT and it's displaying the images fine.

            <xsl:variable name="itemImage" select="./data[@alias='itemContentImage']"/>
            <xsl:if test="$itemImage">
            <img src="{$itemImage}" style="float: left; padding: 0px 10px 10px 0px)" />
            </xsl:if>

    Regards,

    Rachel

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Sep 26, 2011 @ 14:06
    Peter Dijksterhuis
    0

    Good you have it working :)

    To get rid of the html-tags, use this:

    <xsl:value-of select="itemContent" disable-output-escaping="yes"/>

    Peter

  • Rachel Skuse 88 posts 118 karma points
    Sep 26, 2011 @ 14:38
    Rachel Skuse
    0

    Thank you :)

Please Sign in or register to post replies

Write your reply to:

Draft