factoring out some attachment code and support default icons