Copied to clipboard

Flag this post as spam?

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


  • Martin 278 posts 662 karma points
    Mar 30, 2012 @ 14:53
    Martin
    0

    Default Image - Using DAMP

    Hi,

    Im having some trouble implementing a default image. Ive had a look over the forum and found a post regarding default.

    http://our.umbraco.org/forum/templating/templates-and-document-types/8502-Default-media-if-none-selected

    Im using the DAMP for selecting my image, but I cant get the default image to show if a images is not selected.

    Any help would be grateful.

    Thanks

    Martin

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
    <!-- The fun starts here -->
      <xsl:for-each select="$currentPage [@isDoc and string(umbracoNaviHide) != '1']">

      <h3 class="newsHeadline"><xsl:value-of select="@nodeName"/></h3>
      <xsl:apply-templates select="$currentPage/ourWorkThumb[normalize-space()]" />
    </xsl:for-each>

    </xsl:template>
    <xsl:template match="ourWorkThumb">
       <!--<img class="ourWorkThumb" src="{umbraco.library:GetMedia(., 0)/umbracoFile}" />-->
         
        <xsl:choose>
          <xsl:when test="string($currentPage/ourWorkThumb/data[@alias='ourWorkThumb']) = ''">
                    <img class="ourWorkThumb" src="{umbraco.library:GetMedia(., false)/umbracoFile}" />
            </xsl:when>
            <xsl:otherwise>
                    <img src="/images/defaultWorkImage.png" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template
        
    </xsl:stylesheet>
  • Giovanni Sidoel 94 posts 233 karma points
    May 18, 2012 @ 04:14
    Giovanni Sidoel
    0

    Hi Martin,

    Try changing

     <xsl:when test="string($currentPage/ourWorkThumb/data[@alias='ourWorkThumb']) = ''">
                    <img class="ourWorkThumb" src="{umbraco.library:GetMedia(., false)/umbracoFile}" />
            </xsl:when>

    to

     <xsl:when test="string($currentPage/ourWorkThumb/data[@alias='ourWorkThumb']) != ''">
                    <img class="ourWorkThumb" src="{umbraco.library:GetMedia(., false)/umbracoFile}" />
            </xsl:when>

    Note the " != '' " (is not epmty). Basically you got it the other way round.

     

    Gio

Please Sign in or register to post replies

Write your reply to:

Draft