Found out why the code didn't work in the client. It seems that the client expect a completly different URL Format.
Why IBM did it that way is anyones guess...
Here's an updated SSJS for the view display.
(Code for the notes client version adapted from http://www.wissel.net/blog/d6plinks/SHWL-86QKNM)
var dbpfx
var myView = "0" //dummy view name
var myDoc = viewEntry.getColumnValue("unid") // this is a column with the reference 'unid'
var thumbName = "thumbPic.jpg" //hardcoded value in the rich text lite field
if (@ClientType()=="Web"){
// web version
var mydb = @Left(session.getHttpURL(),".nsf")
if (@Length(mydb) == 0){
dbpfx = context.getUrl().getPath() }
return "<img src='" + dbpfx + myView + "/" + myDoc + "/$File/" + thumbName + "' WIDTH=100 HEIGHT=100>"
}
else
{
//Notes Client version
var curURL = context.getUrl();
var curAdr = curURL.getAddress();
var rel = curURL.getSiteRelativeAddress(context);
var step1 = curAdr.substr(0,curAdr.indexOf(rel));
// Now cut off the http
var step2 = step1.substr(step1.indexOf("//")+2);
var base = step2.substr(step2.indexOf("/"));var middle = "/xsp/.ibmmodres/domino/OpenAttachment";if (base.substr(0,4) == "/xsp") {middle += base.substr(4);
} else {middle += base;
}
var result = base + middle + "/" + myDoc + "/$File/" + thumbName + "?Open";return "<img src='" + result + "'/>";}