Attachments

Attachment Functions

$attachments = get_posts("post_type=attachment&post_parent=$postID&numberposts=1&post_status=inherit&mime_type=pdf");

$obj = new stdClass();
$obj->title = apply_filter('the_title', $attachment->post_title);
$obj->url = wp_get_attachment_url($attachment->ID);
$obj->link = wp_get_attachment_link($attachment->ID, $size, $linkToPage, $icon);
$obj->image = wp_get_attachment_image($attachment->ID, $size, false);
$obj->icon = wp_get_attachment_image($attachment->ID, $size, true);

The Attachments WP Plugin

Sets a meta_key @_thumbnail_id@ in wp_postmeta???

Featured Image (Post Thumbnails in WP v2.9 — v2.9.2)

"Use as featured image" Link -- ID: 4
	Alt Text: null
	Caption: null
	Description: null
	inGallery: true
	Media Library isAttached: true
	wp_postmeta: 3/4 _wp_attached_file = 2010/10/annie-thao-18.jpg
	wp_postmeta: 4/4 _wp_attachment_metadata = a:6:{s:5:"width";s:3:"600";s:6:"height";s:3:"896";s:14:"hwstring_small";s:22:"height='96' width='64'";s:4:"file";s:25:"2010/10/annie-thao-18.jpg";s:5:"sizes";a:3:{s:9:"thumbnail";a:3:{s:4:"file";s:25:"annie-thao-18-150x150.jpg";s:5:"width";s:3:"150";s:6:"height";s:3:"150";}s:6:"medium";a:3:{s:4:"file";s:25:"annie-thao-18-200x300.jpg";s:5:"width";s:3:"200";s:6:"height";s:3:"300";}s:14:"post-thumbnail";a:3:{s:4:"file";s:25:"annie-thao-18-600x198.jpg";s:5:"width";s:3:"600";s:6:"height";s:3:"198";}}s:10:"image_meta";a:10:{s:8:"aperture";s:2:"14";s:6:"credit";s:0:"";s:6:"camera";s:9:"NIKON D80";s:7:"caption";s:0:"";s:17:"created_timestamp";s:10:"1238248905";s:9:"copyright";s:0:"";s:12:"focal_length";s:2:"20";s:3:"iso";s:3:"250";s:13:"shutter_speed";s:7:"0.00625";s:5:"title";s:0:"";}}
	wp_postmeta: 5/1 _thumbnail_id = 4

"Save all changes" Button -- ID: 6
	Alt Text: set
	Caption: set
	Description: set
	inGallery: true
	Media Library isAttached: true
	wp_postmeta: 6/6 _wp_attached_file = 2010/10/mcf6zp.jpg
	wp_postmeta: 7/6 _wp_attachment_metadata = a:6:{s:5:"width";s:3:"685";s:6:"height";s:4:"1024"...
	wp_postmeta: 8/6 _wp_attachment_image_alt = Annie Thao

Upload without Saving -- ID: 7
	Alt Text: set
	Caption: null
	Description: null
	inGallery: false
	Media Library isAttached: false
	wp_postmeta: 9/7 _wp_attached_file = 2010/10/IMG_3327Edit1.jpg
	wp_postmeta: 10/7 _wp_attachment_metadata = a:6:{s:5:"width";s:3:"900";s:6:"height";s:3:"600";...

"Attach" Button: (Attachments Plugin?) -- ID: 10
	Alt Text: set
	Caption: set
	Description: set
	inGallery: true
	Media Library isAttached: true
	wp_postmeta: _wp_attached_file = 2010/10/02lrgr.jpg
	wp_postmeta: _wp_attachment_metadata = a:6:{s:5:"width";s:3:"680";s:6:"height";s:4:"1024"...
	wp_postmeta: _wp_attachment_alt = Sammie Pennington

"Insert into Post" Button:

All images uploaded had the three image sizes defined in Settings > Media. The size was appended to the filename with with the filter -WIDTHxHEIGHT.EXT.

IDs: 8, 9, 11

SELECT * FROM wp_posts WHERE post_type = 'attachment' ORDER BY ID;
SELECT * FROM wp_posts WHERE post_parent = 315 ORDER BY ID;
SELECT * FROM wp_posts WHERE ID = 315;
SELECT * FROM wp_postmeta WHERE post_id = 7;

Multiple image attachments may be used to create a [gallary].

Note: header_image() defined via add_custom_image_header()

Images attached via the Media Panel

Defines the parent_id value in the wp_posts table as 0. Games Section Header ID: 248