There are several ways to go about getting the attachment ID (of the ‘attachment’ WordPress post type, stored in the wp_posts WPDB [Wordpress DataBase] table. Here are some of them:
From the Media Library:
Navigate to Dashboard -> Media. Here you will see your WordPress uploads (Media), either in grid view or list view. They’re both fine, it’s just a preference thing. Instructions for both are below.

List View
Use your mouse to hover over the chosen media and watch for the post ID in the lower left hand corner of your browser. In this case, the id is 9479.[/caption]
Grid View
In grid view, it’s a little bit different. You’ve got to click on the media file. A popup window will open up. Take a look in your browser URL bar and you will see the attachment ID there, after where it says “?item=” Like this:
