Hi all,
I want to convert an image's filename to the generated thumbnail for a gallery 
web part I'm creating.

The following works flawlessly provided the user doesn't put any periods in the 
Name column.

Can anyone provide something more robust that perhaps grabs the length of $str 
first and turns the last four characters into the $ext argument?

<!-- Thumbnail Template -->
<xsl:template name="getThumb">
      <xsl:param name="str"/>
      <!-- Convert period to underscore -->
      <xsl:variable name="ext">.</xsl:variable>
      <xsl:choose>
            <xsl:when test="contains($str, $ext)">
                  <xsl:value-of select="substring-before($str, $ext)"/>
                  <xsl:text>_</xsl:text>
                  <xsl:call-template name="getThumb">
                        <xsl:with-param name="str" 
select="substring-before($str, $ext)"></xsl:with-param>
                  </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                  <xsl:value-of select="$str"></xsl:value-of>
            </xsl:otherwise>
      </xsl:choose>
</xsl:template>

<xsl:template name="dvt_1.rowview">
<!-- Create a variable for our thumbnail. -->
      <xsl:variable name="imageThumb">
            <xsl:call-template name="getThumb">
                  <xsl:with-param name="str" 
select="@NameOrTitle"></xsl:with-param>
            </xsl:call-template>
      </xsl:variable>

                <!-- Add default thumb ext to new image name -->
      <img src="/{@FileDirRef}/_t/{$imageThumb}.jpg" alt="{@Description}" />
...
_______________________________________________
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to