Monday, November 30, 2009

Displaying thumbnail using DataViewerWebPart

Displaying thumbnail using dataview webpart may tweaking In order to display thumbnails from a picture library.

You may receive XML errors if you try to do following steps
1. Drop listview webpart for picture library showing thumbnail and name of image
2. Right click and convert it to DataViewWebpart

So you may probably need to do following to resolve it.
1. Drop list view webpart and change its view to show name and url of image.
2. edit your file and replace XSL for displaying URL with following code to display thumbnail.
There is a limitation in a code that it will not be able to diplay thumbnail if you repeat file extension in your file name. So if your file name is like name.gif.gif it will not be able to display its thumbnail.

<img border="0" src="{concat('/',@FileDirRef,'/_t/',
substring-before(translate(@FileLeafRef,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),concat('.',@FileType)),'_',@FileType,'.','jpg')}"
alt="'{@FileRef}'"/>

1 comment: