Fixed rendering of attachments to put files before images, and to turn many images into thumbnails that are linked