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/media.php

    r31624 r31645  
    26542654        </div>
    26552655    <?php
    2656     elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'audio/' ) ):
     2656    elseif ( $attachment_id && wp_attachment_is( 'audio', $post ) ):
    26572657
    26582658        wp_maybe_generate_attachment_metadata( $post );
     
    26602660        echo wp_audio_shortcode( array( 'src' => $att_url ) );
    26612661
    2662     elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'video/' ) ):
     2662    elseif ( $attachment_id && wp_attachment_is( 'video', $post ) ):
    26632663
    26642664        wp_maybe_generate_attachment_metadata( $post );
Note: See TracChangeset for help on using the changeset viewer.