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/includes/ajax-actions.php

    r31626 r31645  
    22912291    }
    22922292
    2293     if ( 0 === strpos( $post['post_mime_type'], 'audio/' ) ) {
     2293    if ( wp_attachment_is( 'audio', $post['ID'] ) ) {
    22942294        $changed = false;
    22952295        $id3data = wp_get_attachment_metadata( $post['ID'] );
     
    24492449        $title = ''; // We no longer insert title tags into <img> tags, as they are redundant.
    24502450        $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt );
    2451     } elseif ( 'video' === substr( $post->post_mime_type, 0, 5 ) || 'audio' === substr( $post->post_mime_type, 0, 5 )  ) {
     2451    } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post )  ) {
    24522452        $html = stripslashes_deep( $_POST['html'] );
    24532453    }
Note: See TracChangeset for help on using the changeset viewer.