Don't show featured images for image attachments. Remove abstractions for now.

fixes #27673.

Built from https://develop.svn.wordpress.org/trunk@28051


git-svn-id: http://core.svn.wordpress.org/trunk@27881 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-04-08 17:40:28 +00:00
parent 4d6fcfdba1
commit e8da400c69
2 changed files with 20 additions and 46 deletions

View File

@ -24,9 +24,16 @@ $post_ID = isset($post_ID) ? (int) $post_ID : 0;
$user_ID = isset($user_ID) ? (int) $user_ID : 0;
$action = isset($action) ? $action : '';
$media_support = theme_supports_thumbnails( $post ) || post_supports_thumbnails( $post );
$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) {
if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
$thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
} elseif ( 0 === strpos( $post->post_mime_type, 'video/' ) ) {
$thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
}
}
if ( post_type_supports( $post_type, 'editor' ) || post_type_supports( $post_type, 'thumbnail' ) || $media_support ) {
if ( $thumbnail_support ) {
add_thickbox();
wp_enqueue_media( array( 'post' => $post_ID ) );
}
@ -169,7 +176,7 @@ foreach ( get_object_taxonomies( $post ) as $tax_name ) {
if ( post_type_supports($post_type, 'page-attributes') )
add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core');
if ( current_theme_supports( 'post-thumbnails', $post_type ) || post_supports_thumbnails( $post ) )
if ( $thumbnail_support )
add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', null, 'side', 'low');
if ( post_type_supports($post_type, 'excerpt') )

View File

@ -2452,7 +2452,16 @@ function wp_enqueue_media( $args = array() ) {
'nonce' => wp_create_nonce( 'update-post_' . $post->ID ),
);
if ( theme_supports_thumbnails( $post ) || post_supports_thumbnails( $post ) ) {
$thumbnail_support = current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' );
if ( ! $thumbnail_support && 'attachment' === $post->post_type && $post->post_mime_type ) {
if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
$thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
} elseif ( 0 === strpos( $post->post_mime_type, 'video/' ) ) {
$thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
}
}
if ( $thumbnail_support ) {
$featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true );
$settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1;
}
@ -2756,45 +2765,3 @@ function wp_maybe_generate_attachment_metadata( $attachment ) {
}
}
}
/**
* Determine if a post supports thumbnails based on the passed post object.
*
* @since 3.9.0
*
* @param WP_Post $post Post object.
*
* @return bool Whether the post type supports thumbnails.
*/
function post_supports_thumbnails( $post ) {
if ( 'attachment' === $post->post_type ) {
if ( 0 === strpos( $post->post_mime_type, 'audio' ) ) {
return post_type_supports( 'attachment:audio', 'thumbnail' );
} elseif ( 0 === strpos( $post->post_mime_type, 'video' ) ) {
return post_type_supports( 'attachment:video', 'thumbnail' );
}
}
return post_type_supports( $post->post_type, 'thumbnail' );
}
/**
* Determine if a theme supports thumbnails based on the passed post object.
*
* @since 3.9.0
*
* @param WP_Post $post Post object.
*
* @return bool Whether the current theme supports thumbnails.
*/
function theme_supports_thumbnails( $post ) {
if ( 'attachment' === $post->post_type ) {
if ( 0 === strpos( $post->post_mime_type, 'audio' ) ) {
return current_theme_supports( 'post-thumbnails', 'attachment:audio' );
} elseif ( 0 === strpos( $post->post_mime_type, 'video' ) ) {
return current_theme_supports( 'post-thumbnails', 'attachment:video' );
}
}
return current_theme_supports( 'post-thumbnails', $post->post_type );
}