I am using the following code to display image using XSLT in Sharepoint. It is working fine.

<xsl:value-of select="@Image">

But this approach doesn't allow me to define width and height of image so I tried to use it like this but it didn't work.

<img src="{@Image}" width="100" height="100">

How to make it work?

  • If you do a <xsl:value-of select="@Image" /> what is output? Nov 20 '13 at 20:38

It depends how the @Image is defined, it will sometimes come through with a description separated by a comma.

If this is the case then you could try substring-before:

<img src="{substring-before(@Image,',')}" width="100" height="100">

Looks like some folks on Stack Overflow asked a similar question https://stackoverflow.com/questions/45904/how-do-you-add-an-image-in-xslt

Few choices over there to try. Good luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.