In sharepoint I have created a content query webpart that queries a list and displays the title and the ImageURL field in 3 column grid format.
For some very strange reason, the code works most of the time and the image and title displays in a grid as I would like. However, if you refresh the page a few times, the image simply does not get found and inserted into the markup. The title does display all the time.
I have created my own Item Style variable in XSL itemStyles.xsl. Here is my code:
<xsl:template name="customStyle" match="Row[@Style='customStyle']" mode="itemstyle">
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="SafeImageUrl">
<xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
<xsl:with-param name="UrlColumnName" select="'ImageURL'"/>
</xsl:call-template>
</xsl:variable>
<div class="item">
<xsl:if test="string-length($SafeImageUrl) != 0">
<a href="{$SafeLinkUrl}">
<img class="image customstyle-img" src="{$SafeImageUrl}" title="{@ImageUrlAltText}" />
</a>
</xsl:if>
</div>
</xsl:template>
I would be grateful if anybody could offer any suggestions.
Oliver