Unfortunately in the Notes client you can't use the $FILE URL syntax. When you use this on the server you're actually using the old HTTP server to serve the attachments up to you, instead you'll need to work out which client is running and then build a different format URL for the Notes client vs the web browser.
Below is a set of functions which you can use (shameless plug.. as taken from my online video training site
XPages101.net), it assumes that the names of the file attachments are in a field called "AttachmentNames". If they aren't then it should be an easy task to work them out.
/**
Builds some HTML to display the photo for a contact
*/
function getImageHTML(doc:NotesDocument){
var files = doc.getItemValue("AttachmentNames");
var out = "";
var dbPath = getDbPath();
for (var i=0; i<files.length; i++){
if (out != "")
out += "<br />";
if (files[i].toLowerCase().indexOf(".jpg") > -1 ||
files[i].toLowerCase().indexOf(".gif") > -1 ||
files[i].toLowerCase().indexOf(".png") > -1)
out += "<img class=\"viewphoto\" src=\"" + dbPath[0] + "/xsp/.ibmmodres/domino/OpenAttachment/" + dbPath[1] + "/" +
doc.getUniversalID() + "/photo/" + escape(files[i]) + "\" />";
}
if (out != "")
out = "<div class=\"screenshotimage\">" + out + "</div>";
return out;
}
/**
Cache the dbPath variables in an applicationScope variable
*/
function getDbPath(){
if(isCacheInvalid("dbpathweb", 600)){
synchronized(applicationScope){
var dbPath = @Left(context.getUrl(), ".nsf") + ".nsf";
var pos = (context.isRunningContext("Notes")) ? 4 : 3;
var secondPathElements = dbPath.split("/");
var secondPath = "";
for (pos; pos<secondPathElements.length; pos++){
if (secondPath != "")
secondPath += "/";
secondPath += secondPathElements[pos];
}
var res:Array = new Array();
res.push(dbPath);
res.push(secondPath);
applicationScope.dbPathWeb = res;
}
}
return applicationScope.dbPathWeb;
}
/**
A generic caching mechanism for each key will check to see if it is 'n' seconds
since it was last updated. Use for things that change relatively infrequently
*/
function isCacheInvalid(key, cacheInterval){
var currentTime = new Date().getTime();
if (!applicationScope.containsKey(key + "_time")){
applicationScope.put(key + "_time", currentTime);
return true;
}
var diffInSecs = Math.ceil((currentTime - applicationScope.get(key + "_time")) / 1000);
if (diffInSecs < cacheInterval) {
return false;
} else {
applicationScope.put(key + "_time", currentTime);
return true;
}
}