Ticket #25275: 25275.diff
File 25275.diff, 7.1 KB (added by , 10 years ago) |
---|
-
src/wp-admin/edit-form-advanced.php
52 52 53 53 $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); 54 54 if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) { 55 if ( 0 === strpos( $post->post_mime_type, 'audio/') ) {55 if ( wp_attachment_is_audio( $post ) ) { 56 56 $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); 57 } elseif ( 0 === strpos( $post->post_mime_type, 'video/') ) {57 } elseif ( wp_attachment_is_video( $post ) ) { 58 58 $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); 59 59 } 60 60 } … … 178 178 add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' ); 179 179 add_action( 'edit_form_after_title', 'edit_form_image_editor' ); 180 180 181 if ( 0 === strpos( $post->post_mime_type, 'audio/') ) {181 if ( wp_attachment_is_audio( $post ) ) { 182 182 add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core' ); 183 183 } 184 184 } else { -
src/wp-admin/includes/ajax-actions.php
2287 2287 } 2288 2288 } 2289 2289 2290 if ( 0 === strpos( $post['post_mime_type'], 'audio/') ) {2290 if ( wp_attachment_is_audio( $post['ID'] ) ) { 2291 2291 $changed = false; 2292 2292 $id3data = wp_get_attachment_metadata( $post['ID'] ); 2293 2293 if ( ! is_array( $id3data ) ) { … … 2445 2445 $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; 2446 2446 $title = ''; // We no longer insert title tags into <img> tags, as they are redundant. 2447 2447 $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt ); 2448 } elseif ( 'video' === substr( $post->post_mime_type, 0, 5 ) || 'audio' === substr( $post->post_mime_type, 0, 5) ) {2448 } elseif ( wp_attachment_is_video( $post ) || wp_attachment_is_audio( $post ) ) { 2449 2449 $html = stripslashes_deep( $_POST['html'] ); 2450 2450 } 2451 2451 -
src/wp-admin/includes/image.php
130 130 } elseif ( preg_match( '#^video/#', get_post_mime_type( $attachment ) ) ) { 131 131 $metadata = wp_read_video_metadata( $file ); 132 132 $support = current_theme_supports( 'post-thumbnails', 'attachment:video' ) || post_type_supports( 'attachment:video', 'thumbnail' ); 133 } elseif ( preg_match( '#^audio/#', get_post_mime_type( $attachment )) ) {133 } elseif ( wp_attachment_is_audio( $attachment ) ) { 134 134 $metadata = wp_read_audio_metadata( $file ); 135 135 $support = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) || post_type_supports( 'attachment:audio', 'thumbnail' ); 136 136 } -
src/wp-admin/includes/media.php
2653 2653 <?php if ( $open ) wp_image_editor( $attachment_id ); ?> 2654 2654 </div> 2655 2655 <?php 2656 elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'audio/') ):2656 elseif ( $attachment_id && wp_attachment_is_audio( $post ) ): 2657 2657 2658 2658 wp_maybe_generate_attachment_metadata( $post ); 2659 2659 2660 2660 echo wp_audio_shortcode( array( 'src' => $att_url ) ); 2661 2661 2662 elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'video/') ):2662 elseif ( $attachment_id && wp_attachment_is_video( $post ) ): 2663 2663 2664 2664 wp_maybe_generate_attachment_metadata( $post ); 2665 2665 -
src/wp-includes/media.php
2976 2976 2977 2977 $thumbnail_support = current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ); 2978 2978 if ( ! $thumbnail_support && 'attachment' === $post->post_type && $post->post_mime_type ) { 2979 if ( 0 === strpos( $post->post_mime_type, 'audio/') ) {2979 if ( wp_attachment_is_audio( $post ) ) { 2980 2980 $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); 2981 } elseif ( 0 === strpos( $post->post_mime_type, 'video/') ) {2981 } elseif ( wp_attachment_is_video( $post ) ) { 2982 2982 $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); 2983 2983 } 2984 2984 } -
src/wp-includes/post-template.php
1550 1550 if ( empty($post->post_type) || $post->post_type != 'attachment' ) 1551 1551 return $content; 1552 1552 1553 if ( 0 === strpos( $post->post_mime_type, 'video') ) {1553 if ( wp_attachment_is_video( $post ) ) { 1554 1554 $meta = wp_get_attachment_metadata( get_the_ID() ); 1555 1555 $atts = array( 'src' => wp_get_attachment_url() ); 1556 1556 if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) { … … 1561 1561 $atts['poster'] = wp_get_attachment_url( get_post_thumbnail_id() ); 1562 1562 } 1563 1563 $p = wp_video_shortcode( $atts ); 1564 } elseif ( 0 === strpos( $post->post_mime_type, 'audio') ) {1564 } elseif ( wp_attachment_is_audio( $post ) ) { 1565 1565 $p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) ); 1566 1566 } else { 1567 1567 $p = '<p class="attachment">'; -
src/wp-includes/post.php
5088 5088 } 5089 5089 5090 5090 /** 5091 * Determine if an attachment is an audio file 5092 * 5093 * @since 4.2.0 5094 * 5095 * @param int|WP_Post $post 5096 * @return bool 5097 */ 5098 function wp_attachment_is_audio( $post ) { 5099 if ( ! $post = get_post( $post ) || ! $file = get_attached_file( $post->ID ) ) { 5100 return false; 5101 } 5102 5103 return ( 0 == strpos( $post->post_mime_type, 'audio/' ) || 5104 ( 5105 $ext = wp_check_filetype( $file ) && $ext['ext'] && 5106 'import' == $post->post_mime_type && 5107 in_array( $ext['ext'], wp_get_audio_extensions() ) 5108 ) 5109 ); 5110 } 5111 5112 /** 5113 * Determine if an attachment is a video 5114 * 5115 * @since 4.2.0 5116 * 5117 * @param int|WP_Post $post 5118 * @return bool 5119 */ 5120 function wp_attachment_is_video( $post ) { 5121 if ( ! $post = get_post( $post ) || ! $file = get_attached_file( $post->ID ) ) { 5122 return false; 5123 } 5124 5125 return ( 0 == strpos( $post->post_mime_type, 'video/' ) || 5126 ( 5127 $ext = wp_check_filetype( $file ) && $ext['ext'] && 5128 'import' == $post->post_mime_type && 5129 in_array( $ext['ext'], wp_get_video_extensions() ) 5130 ) 5131 ); 5132 } 5133 5134 /** 5091 5135 * Retrieve the icon for a MIME type. 5092 5136 * 5093 5137 * @since 2.1.0