WordPress.org

Make WordPress Core

Changeset 28051


Ignore:
Timestamp:
04/08/14 17:39:58 (14 months ago)
Author:
nacin
Message:

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

fixes #27673.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-advanced.php

    r28029 r28051  
    2525$action = isset($action) ? $action : ''; 
    2626 
    27 $media_support = theme_supports_thumbnails( $post ) || post_supports_thumbnails( $post ); 
    28  
    29 if ( post_type_supports( $post_type, 'editor' ) || post_type_supports( $post_type, 'thumbnail' ) || $media_support ) { 
     27$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); 
     28if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) { 
     29    if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) { 
     30        $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); 
     31    } elseif ( 0 === strpos( $post->post_mime_type, 'video/' ) ) { 
     32        $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); 
     33    } 
     34} 
     35 
     36if ( $thumbnail_support ) { 
    3037    add_thickbox(); 
    3138    wp_enqueue_media( array( 'post' => $post_ID ) ); 
     
    170177    add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core'); 
    171178 
    172 if ( current_theme_supports( 'post-thumbnails', $post_type ) || post_supports_thumbnails( $post ) ) 
     179if ( $thumbnail_support ) 
    173180    add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', null, 'side', 'low'); 
    174181 
  • trunk/src/wp-includes/media.php

    r28050 r28051  
    24532453        ); 
    24542454 
    2455         if ( theme_supports_thumbnails( $post ) || post_supports_thumbnails( $post ) ) { 
     2455        $thumbnail_support = current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ); 
     2456        if ( ! $thumbnail_support && 'attachment' === $post->post_type && $post->post_mime_type ) { 
     2457            if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) { 
     2458                $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); 
     2459            } elseif ( 0 === strpos( $post->post_mime_type, 'video/' ) ) { 
     2460                $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); 
     2461            } 
     2462        } 
     2463 
     2464        if ( $thumbnail_support ) { 
    24562465            $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true ); 
    24572466            $settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; 
     
    27572766    } 
    27582767} 
    2759  
    2760 /** 
    2761  * Determine if a post supports thumbnails based on the passed post object. 
    2762  * 
    2763  * @since 3.9.0 
    2764  * 
    2765  * @param WP_Post $post Post object. 
    2766  * 
    2767  * @return bool Whether the post type supports thumbnails. 
    2768  */ 
    2769 function post_supports_thumbnails( $post ) { 
    2770     if ( 'attachment' === $post->post_type ) { 
    2771         if ( 0 === strpos( $post->post_mime_type, 'audio' ) ) { 
    2772             return post_type_supports( 'attachment:audio', 'thumbnail' ); 
    2773         } elseif ( 0 === strpos( $post->post_mime_type, 'video' ) ) { 
    2774             return post_type_supports( 'attachment:video', 'thumbnail' ); 
    2775         } 
    2776     } 
    2777  
    2778     return post_type_supports( $post->post_type, 'thumbnail' ); 
    2779 } 
    2780  
    2781 /** 
    2782  * Determine if a theme supports thumbnails based on the passed post object. 
    2783  * 
    2784  * @since 3.9.0 
    2785  * 
    2786  * @param WP_Post $post Post object. 
    2787  * 
    2788  * @return bool Whether the current theme supports thumbnails. 
    2789  */ 
    2790 function theme_supports_thumbnails( $post ) { 
    2791     if ( 'attachment' === $post->post_type ) { 
    2792         if ( 0 === strpos( $post->post_mime_type, 'audio' ) ) { 
    2793             return current_theme_supports( 'post-thumbnails', 'attachment:audio' ); 
    2794         } elseif ( 0 === strpos( $post->post_mime_type, 'video' ) ) { 
    2795             return current_theme_supports( 'post-thumbnails', 'attachment:video' ); 
    2796         } 
    2797     } 
    2798  
    2799     return current_theme_supports( 'post-thumbnails', $post->post_type ); 
    2800 } 
Note: See TracChangeset for help on using the changeset viewer.