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-includes/post-template.php

    r31600 r31645  
    15511551        return $content;
    15521552
    1553     if ( 0 === strpos( $post->post_mime_type, 'video' ) ) {
     1553    if ( wp_attachment_is( 'video', $post ) ) {
    15541554        $meta = wp_get_attachment_metadata( get_the_ID() );
    15551555        $atts = array( 'src' => wp_get_attachment_url() );
     
    15621562        }
    15631563        $p = wp_video_shortcode( $atts );
    1564     } elseif ( 0 === strpos( $post->post_mime_type, 'audio' ) ) {
     1564    } elseif ( wp_attachment_is( 'audio', $post ) ) {
    15651565        $p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) );
    15661566    } else {
Note: See TracChangeset for help on using the changeset viewer.