Fix bug with image attachments loading too early, and broken image attachments