diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php
index 295b96a8f3..d6a8480dcb 100644
--- a/src/wp-admin/edit-form-advanced.php
+++ b/src/wp-admin/edit-form-advanced.php
@@ -52,9 +52,9 @@ if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content )
$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) {
- if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
+ if ( wp_attachment_is( 'audio', $post ) ) {
$thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
- } elseif ( 0 === strpos( $post->post_mime_type, 'video/' ) ) {
+ } elseif ( wp_attachment_is( 'video', $post ) ) {
$thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
}
}
@@ -178,7 +178,7 @@ if ( 'attachment' == $post_type ) {
add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
add_action( 'edit_form_after_title', 'edit_form_image_editor' );
- if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
+ if ( wp_attachment_is( 'audio', $post ) ) {
add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core' );
}
} else {
diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
index b576badc7f..81ba091519 100644
--- a/src/wp-admin/includes/ajax-actions.php
+++ b/src/wp-admin/includes/ajax-actions.php
@@ -2290,7 +2290,7 @@ function wp_ajax_save_attachment() {
}
}
- if ( 0 === strpos( $post['post_mime_type'], 'audio/' ) ) {
+ if ( wp_attachment_is( 'audio', $post['ID'] ) ) {
$changed = false;
$id3data = wp_get_attachment_metadata( $post['ID'] );
if ( ! is_array( $id3data ) ) {
@@ -2448,7 +2448,7 @@ function wp_ajax_send_attachment_to_editor() {
$caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : '';
$title = ''; // We no longer insert title tags into tags, as they are redundant.
$html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt );
- } elseif ( 'video' === substr( $post->post_mime_type, 0, 5 ) || 'audio' === substr( $post->post_mime_type, 0, 5 ) ) {
+ } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) {
$html = stripslashes_deep( $_POST['html'] );
}
diff --git a/src/wp-admin/includes/image.php b/src/wp-admin/includes/image.php
index 25a49cef5b..9171247d2f 100644
--- a/src/wp-admin/includes/image.php
+++ b/src/wp-admin/includes/image.php
@@ -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' );
}
diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php
index b08498f9dd..5f6d08c7ab 100644
--- a/src/wp-admin/includes/media.php
+++ b/src/wp-admin/includes/media.php
@@ -2653,13 +2653,13 @@ function edit_form_image_editor( $post ) {
post_mime_type, 'audio/' ) ):
+ elseif ( $attachment_id && wp_attachment_is( 'audio', $post ) ):
wp_maybe_generate_attachment_metadata( $post );
echo wp_audio_shortcode( array( 'src' => $att_url ) );
- elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'video/' ) ):
+ elseif ( $attachment_id && wp_attachment_is( 'video', $post ) ):
wp_maybe_generate_attachment_metadata( $post );
diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index cb2f25f98d..a9965651f9 100644
--- a/src/wp-includes/media.php
+++ b/src/wp-includes/media.php
@@ -2976,9 +2976,9 @@ function wp_enqueue_media( $args = array() ) {
$thumbnail_support = current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' );
if ( ! $thumbnail_support && 'attachment' === $post->post_type && $post->post_mime_type ) {
- if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
+ if ( wp_attachment_is( 'audio', $post ) ) {
$thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
- } elseif ( 0 === strpos( $post->post_mime_type, 'video/' ) ) {
+ } elseif ( wp_attachment_is( 'video', $post ) ) {
$thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
}
}
diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php
index 735bfad032..4d54178ee2 100644
--- a/src/wp-includes/post-template.php
+++ b/src/wp-includes/post-template.php
@@ -1550,7 +1550,7 @@ function prepend_attachment($content) {
if ( empty($post->post_type) || $post->post_type != 'attachment' )
return $content;
- if ( 0 === strpos( $post->post_mime_type, 'video' ) ) {
+ if ( wp_attachment_is( 'video', $post ) ) {
$meta = wp_get_attachment_metadata( get_the_ID() );
$atts = array( 'src' => wp_get_attachment_url() );
if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
@@ -1561,7 +1561,7 @@ function prepend_attachment($content) {
$atts['poster'] = wp_get_attachment_url( get_post_thumbnail_id() );
}
$p = wp_video_shortcode( $atts );
- } elseif ( 0 === strpos( $post->post_mime_type, 'audio' ) ) {
+ } elseif ( wp_attachment_is( 'audio', $post ) ) {
$p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) );
} else {
$p = '