mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 21:00:21 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@31645 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -127,10 +127,10 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
||||
if ( $image_meta )
|
||||
$metadata['image_meta'] = $image_meta;
|
||||
|
||||
} elseif ( preg_match( '#^video/#', get_post_mime_type( $attachment ) ) ) {
|
||||
} elseif ( wp_attachment_is( 'video', $attachment ) ) {
|
||||
$metadata = wp_read_video_metadata( $file );
|
||||
$support = current_theme_supports( 'post-thumbnails', 'attachment:video' ) || post_type_supports( 'attachment:video', 'thumbnail' );
|
||||
} elseif ( preg_match( '#^audio/#', get_post_mime_type( $attachment ) ) ) {
|
||||
} elseif ( wp_attachment_is( 'audio', $attachment ) ) {
|
||||
$metadata = wp_read_audio_metadata( $file );
|
||||
$support = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) || post_type_supports( 'attachment:audio', 'thumbnail' );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user