Get src attribute from Publishing Image field

21/10/2013 16:51

Get src attribute from Publishing Image field

PublishingPageImage is sharepoint column and user can select image via item picker.

To get src attribute for xslt, use following code

 

Image src: <xsl:value-of select="@PublishingPageImage"/><br></br>
 <xsl:variable name="firstPart"><xsl:value-of select="substring-after(@PublishingPageImage, 'src=')"/></xsl:variable>
 Image src:<xsl:value-of select="substring-before($firstPart, ' ')" />

 

Image used as background image

<div class="itemBg">
  <xsl:attribute name="style">
   background-image: url(<xsl:value-of select="substring-before($firstPart, ' ')" />);
  </xsl:attribute>
</div>