Copied to clipboard

Flag this post as spam?

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


  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Dec 31, 2011 @ 11:39
    Bjarne Fyrstenborg
    0

    AltImage not showing in for-each

    Hi..

    I have a problem with the altImage not is showing when it's inside a loop..
    The altImage is shown in the product list here: http://sub.ak-security.dk/da/shop/radioer-plus-tilbehoer.aspx

    <img src="{concat('/ImageGen.ashx?altImage=/gfx/no_image.gif&amp;Image=',./productImage/DAMP/mediaItem[1]/Image/umbracoFile,'&amp;Width=',$imgWidth)}" class="productImage" alt="{$productName}" title="{$productName}" width="{$imgWidth}" height="{$imgHeight}" />
    

    on product page the image is shown if I have chosen one, but not if I haven't chosen an image:
    http://sub.ak-security.dk/da/shop/radioer-plus-tilbehoer/tyt-th-f6-radio.aspx (with image)

    http://sub.ak-security.dk/da/shop/radioer-plus-tilbehoer/motorola-radio.aspx (without image chosen)

    <xsl:for-each select="./productImage/DAMP/mediaItem/Image">
      <img src="{concat('/ImageGen.ashx?altImage=/gfx/no_image.gif&amp;Image=',./umbracoFile,'&amp;Width=',$imgWidth)}" id="productImage" alt="{$productName}" title="{$productName}" width="{$imgWidth}" height="{$imgHeight}" />
    </xsl:for-each>
    

    Bjarne

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Dec 31, 2011 @ 12:10
    Jan Skovgaard
    0

    Hi Bjarne

    Where in the code do you define the $productName variable?

    /Jan

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Dec 31, 2011 @ 12:25
    Bjarne Fyrstenborg
    0

    Hi Jan..

    It's defined in the start of the xslt:
    <xsl:variable name="productName" select="teacommerce:GetProperty($variant, 'productName')" />

    But it doesn't make a difference if I remove the  alt and title values.

    It display the altImage on product page if a place a single image outside the for-each just the same way as on product list..
    There is no problem with displaying the images in for-each: 
    http://sub.ak-security.dk/da/shop/radioer-plus-tilbehoer/tyt-th-f6-radio.aspx but the altImage doesn't seem to work there.

    Bjarne 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Dec 31, 2011 @ 12:33
    Jan Skovgaard
    0

    Hi Bjarne

    Sorry, #h5is! Read it wrong.

    Is it the exact same XSLT rendering you're using in the two views? the altimage attribute is never written to the source on the view with the related products.

    Could you perhaps post all the XSLT you're using to generate the related products view?

    /Jan

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Dec 31, 2011 @ 12:57
    Bjarne Fyrstenborg
    0

    Hi Jan

    it's the product image I have a problem with ... the relatedProducts.xslt is called into the product_product.xslt file... and it seems to work on related products with altImage.. I just changed it from the default "hello world" text to an altImage: http://sub.ak-security.dk/da/shop/radioer-plus-tilbehoer/tyt-th-f6-radio.aspx

    On that page the image is displayed, but not on pages with no image chosen: http://sub.ak-security.dk/da/shop/radioer-plus-tilbehoer/motorola-radio.aspx

    The related products get the image this way:

    <xsl:variable name="relatedProducts" select="$currentPage/parent::ProductCategory/Product [@id != $currentPage/@id]"/>
    <ul id="relatedProducts">
    <xsl:for-each select="$relatedProducts">
    <li>
         <href="{$productLink}" title="{productName}">
            <img src="{concat('/ImageGen.ashx?altImage=/gfx/no_image.gif&amp;Image=',./productImage/DAMP/mediaItem/Image/umbracoFile,'&amp;Width=',120)}" alt="" />
         </a>
    </li>
    </xsl:for-each>
    </ul> 

    The product image:

    <ul>
    <xsl:for-each select="./productImage/DAMP/mediaItem/Image">
       <li>
          <xsl:variable name="tempImgWidth" select="'250'"/>
                  <xsl:variable name="scale" select="number(umbracoWidth) div $tempImgWidth"/>
                  <xsl:variable name="tempImgHeight" select="round(number(umbracoHeight) div $scale)"/>
                
                  <xsl:variable name="imgWidth">
                  <xsl:choose>
                    <xsl:when test="number(umbracoWidth) &gt; 250">250</xsl:when>
                    <xsl:when test="number(umbracoWidth) &lt;= 250"><xsl:value-of select="number(umbracoWidth)" disable-output-escaping="yes"/></xsl:when>
                    <xsl:otherwise>250</xsl:otherwise>
                  </xsl:choose>
                  </xsl:variable>
                  
                  <xsl:variable name="imgHeight">
                  <xsl:choose>
                    <xsl:when test="$tempImgHeight &gt; 250">250</xsl:when>
                    <xsl:when test="$tempImgHeight &lt;= 250"><xsl:value-of select="tempImgHeight" disable-output-escaping="yes"/></xsl:when>
                    <xsl:otherwise>250</xsl:otherwise>
                  </xsl:choose>
                  </xsl:variable>
                  
                  <xsl:choose>
                    <xsl:when test="./umbracoWidth &gt; '350'">
                       <rev="productImages" rel="zoomHeight:350, zoomWidth:350, adjustX: -30, adjustY:0, smoothMove:3, lensOpacity:0.0, tintOpacity:0.5, tint: '#ffffff', position:'left'" id="zoom1" class='cloud-zoom' href="{concat('/ImageGen.ashx?altImage=/gfx/no_image.gif&amp;Image=',./umbracoFile)}">
                         <img src="{concat('/ImageGen.ashx?altImage=/gfx/no_image.gif&amp;Image=',./umbracoFile,'&amp;Width=',$imgWidth)}" id="productImage" alt="{$productName}" title="{$productName}" width="{$imgWidth}" height="{$imgHeight}" />
                       </a>
                    </xsl:when>
                    <xsl:otherwise>
                      <img src="{concat('/ImageGen.ashx?altImage=/gfx/no_image.gif&amp;Image=',./umbracoFile,'&amp;Width=',$imgWidth)}" id="productImage" alt="{$productName}" title="{$productName}" width="{$imgWidth}" height="{$imgHeight}" />
                    </xsl:otherwise>
                  </xsl:choose> 
       </li>
    </xsl:for-each>
    </ul> 

    Bjarne

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Dec 31, 2011 @ 13:04
    Jan Skovgaard
    1

    Hi Bjarne

    Forgive me being a bit slow on this - finally I get what you mean.

    But doesn't it make sense that no images are being shown at all? I mean you're looping over all the "Image" types...but if no images is selected it won't loop over any of them, right?

    I guess you need to do a count()...like this...

    <xsl:choose>
    <xsl:when test="count(./productImage/DAMP/mediaItem/Image) = '0'>
    <!-- call your alt image here -->
    </xsl:when>
    <xsl:otherwise>
    <!-- your loop here -->
    </xsl:otherwise>
    </xsl:choose>

    Hope this helps.

    /Jan

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Dec 31, 2011 @ 13:18
    Bjarne Fyrstenborg
    0

    Heh.. perhaps I wasn't precise enough on what I meant :)

    I think it's because I use Image in for-each: ./productImage/DAMP/mediaItem/Image ... when I replace that with just ./productImage I also get the altImage.. but then of cource not the selected image with DAMP. It also make sense, cause when no images is selected, there are no Images to loop and therefore I don't get any output inside the <ul> tags...

    So I think the easist way is to do the for-each on ./productImage ... and then I have removed ./DAMP/mediaItem/Image from the for-each and pasted it before umbracoFile, umbracoWidth, umbracoHeight inside the loop.. and then it works :)

    Thanks for your help Jan and happy new year :)

    Bjarne

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Dec 31, 2011 @ 13:38
    Jan Skovgaard
    0

    Hi Bjarne

    I'm glad to see you're able to move on :)

    And a very happy new year to you as well!

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft