﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
15779	Can't add featured images to custom post types	somatic	nacin	"In all the 3.1 beta builds, up to 3.1-beta1-16723, whenever I try to add a featured image to a custom post type item, through the media uploader thickbox, clicking ""use as featured image"", the Featured Image metabox content shows ""-1"", and no image.

This is with a custom post type whose 'capability_type' is set to a custom value (not ""post"").

I've tracked the ""-1"" output down to wp-admin/admin-ajax.php, line 1425

{{{
if ( !current_user_can( 'edit_post', $post_ID ) )
	die( '-1' );
}}}

This code seems unchanged from WP 3.0 - 3.0.3, where I didn't have this problem. I'm assuming something has changed in 3.1 with regards to map_meta_cap or other custom post type capability checking.

AFAIK, the conditional is failing because the $post_ID being checked isn't ""post"" type, and so the capability ""edit_post"" doesn't apply.

If I manually change ""edit_post"" to ""edit_mycustomtype"", the test works, and the featured image thumbnail shows up in the proper metabox.

I don't know that this is a proper solution, as a custom post type's capability type could technically be set to ''anything'', but this fix at least checks the capability against the post type's name (which is how I usually do it):

{{{
$post_type = get_post_type( $post_ID );
if ( !current_user_can( 'edit_' . $post_type, $post_ID ) )
die( '-1' );
}}}
"	defect (bug)	closed	normal	3.1	Post Thumbnails	3.1	critical	fixed		israel@…
