Make WordPress Core


Ignore:
Timestamp:
03/06/2015 08:25:09 PM (10 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/includes/image.php

    r31462 r31645  
    128128            $metadata['image_meta'] = $image_meta;
    129129
    130     } elseif ( preg_match( '#^video/#', get_post_mime_type( $attachment ) ) ) {
     130    } elseif ( wp_attachment_is( 'video', $attachment ) ) {
    131131        $metadata = wp_read_video_metadata( $file );
    132132        $support = current_theme_supports( 'post-thumbnails', 'attachment:video' ) || post_type_supports( 'attachment:video', 'thumbnail' );
    133     } elseif ( preg_match( '#^audio/#', get_post_mime_type( $attachment ) ) ) {
     133    } elseif ( wp_attachment_is( 'audio', $attachment ) ) {
    134134        $metadata = wp_read_audio_metadata( $file );
    135135        $support = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) || post_type_supports( 'attachment:audio', 'thumbnail' );
Note: See TracChangeset for help on using the changeset viewer.