Turn on thumbnail support for `attachment:audio` and `attachment:video`. Change conditionals to check for theme OR post type support when determining whether to turn on the Featured Image UI pieces in the admin.
Fixes #27460. Built from https://develop.svn.wordpress.org/trunk@27657 git-svn-id: http://core.svn.wordpress.org/trunk@27500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
960b8f86ef
commit
38d1fb971f
|
@ -24,13 +24,9 @@ $post_ID = isset($post_ID) ? (int) $post_ID : 0;
|
|||
$user_ID = isset($user_ID) ? (int) $user_ID : 0;
|
||||
$action = isset($action) ? $action : '';
|
||||
|
||||
$media_type = false;
|
||||
if ( 'attachment' === $post_type && $post_ID ) {
|
||||
$post = get_post( $post_ID );
|
||||
$media_type = post_supports_thumbnails( $post );
|
||||
}
|
||||
$media_support = theme_supports_thumbnails( $post ) || post_supports_thumbnails( $post );
|
||||
|
||||
if ( post_type_supports( $post_type, 'editor' ) || post_type_supports( $post_type, 'thumbnail' ) || $media_type ) {
|
||||
if ( post_type_supports( $post_type, 'editor' ) || post_type_supports( $post_type, 'thumbnail' ) || $media_support ) {
|
||||
add_thickbox();
|
||||
wp_enqueue_media( array( 'post' => $post_ID ) );
|
||||
}
|
||||
|
@ -169,14 +165,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');
|
||||
|
||||
$audio_post_support = $video_post_support = false;
|
||||
$theme_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
|
||||
if ( 'attachment' === $post_type && ! empty( $post->post_mime_type ) ) {
|
||||
$audio_post_support = 0 === strpos( $post->post_mime_type, 'audio/' ) && current_theme_supports( 'post-thumbnails', 'attachment:audio' ) && post_type_supports( 'attachment:audio', 'thumbnail' );
|
||||
$video_post_support = 0 === strpos( $post->post_mime_type, 'video/' ) && current_theme_supports( 'post-thumbnails', 'attachment:video' ) && post_type_supports( 'attachment:video', 'thumbnail' );
|
||||
}
|
||||
|
||||
if ( $theme_support || $audio_post_support || $video_post_support )
|
||||
if ( current_theme_supports( 'post-thumbnails', $post_type ) || post_supports_thumbnails( $post ) )
|
||||
add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', null, 'side', 'low');
|
||||
|
||||
if ( post_type_supports($post_type, 'excerpt') )
|
||||
|
|
|
@ -127,10 +127,10 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
|||
|
||||
} elseif ( preg_match( '#^video/#', get_post_mime_type( $attachment ) ) ) {
|
||||
$metadata = wp_read_video_metadata( $file );
|
||||
$support = current_theme_supports( 'post-thumbnails', 'attachment:video' ) && post_type_supports( 'attachment:video', 'thumbnail' );
|
||||
$support = current_theme_supports( 'post-thumbnails', 'attachment:video' ) || post_type_supports( 'attachment:video', 'thumbnail' );
|
||||
} elseif ( preg_match( '#^audio/#', get_post_mime_type( $attachment ) ) ) {
|
||||
$metadata = wp_read_audio_metadata( $file );
|
||||
$support = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) && post_type_supports( 'attachment:audio', 'thumbnail' );
|
||||
$support = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) || post_type_supports( 'attachment:audio', 'thumbnail' );
|
||||
}
|
||||
|
||||
if ( $support && ! empty( $metadata['image']['data'] ) ) {
|
||||
|
|
|
@ -2445,7 +2445,7 @@ function wp_enqueue_media( $args = array() ) {
|
|||
'nonce' => wp_create_nonce( 'update-post_' . $post->ID ),
|
||||
);
|
||||
|
||||
if ( theme_supports_thumbnails( $post ) && post_supports_thumbnails( $post ) ) {
|
||||
if ( theme_supports_thumbnails( $post ) || post_supports_thumbnails( $post ) ) {
|
||||
$featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true );
|
||||
$settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ function create_initial_post_types() {
|
|||
'delete_with_user' => true,
|
||||
'supports' => array( 'title', 'author', 'comments' ),
|
||||
) );
|
||||
add_post_type_support( 'attachment:audio', 'thumbnail' );
|
||||
add_post_type_support( 'attachment:video', 'thumbnail' );
|
||||
|
||||
register_post_type( 'revision', array(
|
||||
'labels' => array(
|
||||
|
|
Loading…
Reference in New Issue