Most of the time, after every WP migration, specially if you’re migrating from WordPress.com to a self-hosted WordPress blog, your images inside your media library will automatically become unattached. You can fix this manually by editing each and every image in your media library and attaching it to the specific post where it was attached before migration.
But is there a faster and quicker way to attach all unattached files automatically? Of course there is. I’ve been searching for it since I’ve migrated one of my friend’s site to a self-hosted WP blog from WordPress.com and I found this very useful thread in the WP support forums.
Anyway, to make this post short, there’s a nifty plugin that was shared by oomskaap. I downloaded and tested the plugin and it actually works. If you also want to automatically attach unattached images in your WP blog, just download this plugin. (I uploaded it in my blog in case the plugin that was uploaded in sockshare.com disappears.)
And oh, you can fork it in Github if you want.