Make WordPress Core


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

    r31574 r31645  
    29772977        $thumbnail_support = current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' );
    29782978        if ( ! $thumbnail_support && 'attachment' === $post->post_type && $post->post_mime_type ) {
    2979             if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
     2979            if ( wp_attachment_is( 'audio', $post ) ) {
    29802980                $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
    2981             } elseif ( 0 === strpos( $post->post_mime_type, 'video/' ) ) {
     2981            } elseif ( wp_attachment_is( 'video', $post ) ) {
    29822982                $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
    29832983            }
Note: See TracChangeset for help on using the changeset viewer.