Smart Attachments (a paid add-on) looks like it should do that and more. One of the bullet points from the overview:
Disclosure! We're friends with the guys at Stiltsoft, and that's how I happen to know of this particular plugin, but I haven't used it personally.
Atlassian Summit is an excellent opportunity for in-person support, training, and networking.Learn more
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG