From 38d1fb971f06ec256f316ac78ad50fed620f4b5e Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 23 Mar 2014 02:35:14 +0000 Subject: [PATCH] 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 --- wp-admin/edit-form-advanced.php | 17 +++-------------- wp-admin/includes/image.php | 4 ++-- wp-includes/media.php | 2 +- wp-includes/post.php | 2 ++ 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index f10490e21f..f7b22812ae 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -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') ) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 07c4f8ece9..3cb7764afc 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -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'] ) ) { diff --git a/wp-includes/media.php b/wp-includes/media.php index be8772b2d7..f038c39838 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -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; } diff --git a/wp-includes/post.php b/wp-includes/post.php index 9240e55d28..b3566fbfac 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -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(