Redirect attachment pages to their parent page (301), when possible, otherwise to the blog home page (302).
In WordPress, attachments default to having their own pages. Sometimes, this is not desirable, as in search engine results. Use this small plugin to redirect your attachment pages to the post parent using a 301 redirect (post parents are also searched for by post name). If an attachment parent post cannot be found, it redirects to your blog home page with a 302 redirect.