Is there a specific reason you need to show the image in the html snippet widget? Why not use the image widget for this?
And where are the images stored?
Try something along these lines with the HTMLSnippet with context
try{
if(
this.contextObj!=null
){
this.domNode.append(
dojo.create(
'img',
{
'src':'/file?guid='+this.contextObj.getGuid()+'?cachebust='+(new Date().getTime())
}
);
);
}else{
dojo.empty(
this.domNode
);
}
}catch(e){
}