Make WordPress Core


Ignore:
Timestamp:
03/06/2015 08:25:09 PM (9 years ago)
Author:
wonderboymusic
Message:

Introduce a function, wp_attachment_is( $type, $post = 0 ), to collapse the logic for determining whether an attachment is an image, audio, or video.

This is admittedly a first pass. There needs to be a generic handler for when any other type is passed, but for now it accepts the whitelist.

See #25275.

File:
1 edited

Legend:

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

    r31550 r31645  
    5353$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
    5454if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) {
    55     if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
     55    if ( wp_attachment_is( 'audio', $post ) ) {
    5656        $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
    57     } elseif ( 0 === strpos( $post->post_mime_type, 'video/' ) ) {
     57    } elseif ( wp_attachment_is( 'video', $post ) ) {
    5858        $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
    5959    }
     
    179179    add_action( 'edit_form_after_title', 'edit_form_image_editor' );
    180180
    181     if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
     181    if ( wp_attachment_is( 'audio', $post ) ) {
    182182        add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core' );
    183183    }
Note: See TracChangeset for help on using the changeset viewer.