4

I have a Contenttype with a custom Image with formatting and constraints for publishing -- StockImg.
I have a rollup of all listitems with this Contenttype.
In my ItemStyle.xsl I have created a custom itemstyle

<xsl:template name="StockDisplay" match="Row[@Style='StockDisplay']" 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>
    <xsl:variable name="DisplayTitle">
      <xsl:call-template name="OuterTemplate.GetTitle">
        <xsl:with-param name="Title" select="substring(@Title, 0 ,25)"/>
        <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="StockImg">
      <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
         <xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
      </xsl:call-template>
    </xsl:variable>
    ...
    <img class="image" src="{$StockImg}" title="" style="border: none;">
    ...
</xsl:template>

in which I would like to get the img url from my custom Publishing Image Field.

I know that by default, you'd use this:

<xsl:variable name="SafeImageUrl">
  <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
    <xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
  </xsl:call-template>
</xsl:variable>

But since I want to retrieve the URL from a custom image field, this isn't doing the job for me.
How do I use the above variable to retrieve the URL from my custom image field?

2
  • What type are you using for you image field? Is it a "Hyperlink or Picture" field with the URL formatted as a picture? Nov 30, 2011 at 11:57
  • @EStruyf It's the Image with formatting and constraints for publishing field type
    – user2536
    Nov 30, 2011 at 12:08

1 Answer 1

6

The format of the Image with formatting and constraints for publishing is already with the image HTML tags.

Ex.:

<img alt="" src="Docs/Image.png" style="border: 0px solid" />

So you could try to do the following:

<xsl:value-of select="substring-before(substring-after(@ImageField, 'src=&quot;'), '&quot; style')" />
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.