I wrote a custom transformation:
public string GetFileExtension(object attachmentGuid)
{
AttachmentManager am = new AttachmentManager();
DataSet ds = am.GetAttachments(string.Format("AttachmentGUID = '{0}'", attachmentGuid.ToString()), "AttachmentOrder", false);
if (ds.Tables[0].Rows.Count > 0)
{
var attachment = am.GetAttachmentInfo(ds.Tables[0].Rows[0]["AttachmentGUID"].ToString(), CMSContext.Current.SiteName);
return attachment.AttachmentExtension;
}
return "";
}
And then used it like this:
<img src="<%# GetAttachmentIconUrl(GetFileExtension(Eval("FileAttachment")), "List") %>" />