| 227 | if ( preg_match( '#^audio#', $type ) ) { |
| 228 | $meta = wp_read_audio_metadata( $file ); |
| 229 | |
| 230 | if ( ! empty( $meta['title'] ) ) |
| 231 | $title = $meta['title']; |
| 232 | |
| 233 | $content = ''; |
| 234 | |
| 235 | if ( ! empty( $title ) ) { |
| 236 | |
| 237 | if ( ! empty( $meta['album'] ) && ! empty( $meta['artist'] ) ) { |
| 238 | $content .= sprintf( _x( '“%1$s” from %2$s by %3$s.', 'Audio track title from album title by artist name' ), $title, $meta['album'], $meta['artist'] ); |
| 239 | } else if ( ! empty( $meta['album'] ) ) { |
| 240 | $content .= sprintf( _x( '“%1$s” from %2$s.', 'Audio track title from album title' ), $title, $meta['album'] ); |
| 241 | } else if ( ! empty( $meta['artist'] ) ) { |
| 242 | $content .= sprintf( _x( '“%1$s” by %2$s.', 'Audio track title by artist name' ), $title, $meta['artist'] ); |
| 243 | } else { |
| 244 | $content .= sprintf( _x( '“%s”.', 'Audio track title' ), $title ); |
| 245 | } |
| 246 | |
| 247 | } else if ( ! empty( $meta['album'] ) ) { |
| 248 | |
| 249 | if ( ! empty( $meta['artist'] ) ) { |
| 250 | $content .= sprintf( _x( '%1$s by %2$s.', 'Audio album title by artist name' ), $meta['album'], $meta['artist'] ); |
| 251 | } else { |
| 252 | $content .= $meta['album'] . '.'; |
| 253 | } |
| 254 | |
| 255 | } else if ( ! empty( $meta['artist'] ) ) { |
| 256 | |
| 257 | $content .= $meta['artist'] . '.'; |
| 258 | |
| 259 | } |
| 260 | |
| 261 | if ( ! empty( $meta['year'] ) ) |
| 262 | $content .= ' ' . sprintf( __( 'Released: %d.' ), $meta['year'] ); |
| 263 | |
| 264 | if ( ! empty( $meta['track_number'] ) ) { |
| 265 | $track_number = explode( '/', $meta['track_number'] ); |
| 266 | if ( isset( $track_number[1] ) ) |
| 267 | $content .= ' ' . sprintf( __( 'Track %1$s of %2$s.' ), number_format_i18n( $track_number[0] ), number_format_i18n( $track_number[1] ) ); |
| 268 | else |
| 269 | $content .= ' ' . sprintf( __( 'Track %1$s.' ), number_format_i18n( $track_number[0] ) ); |
| 270 | } |
| 271 | |
| 272 | if ( ! empty( $meta['genre'] ) ) |
| 273 | $content .= ' ' . sprintf( __( 'Genre: %s.' ), $meta['genre'] ); |
| 274 | |
2393 | | <?php if ( $media_dims ) : ?> |
| 2448 | <?php |
| 2449 | if ( preg_match( '#^audio|video#', $post->post_mime_type ) ): |
| 2450 | |
| 2451 | $fields = array( |
| 2452 | 'mime_type' => __( 'Mime-type:' ), |
| 2453 | 'year' => __( 'Year:' ), |
| 2454 | 'genre' => __( 'Genre:' ), |
| 2455 | 'length_formatted' => __( 'Length:' ), |
| 2456 | ); |
| 2457 | |
| 2458 | foreach ( $fields as $key => $label ): |
| 2459 | if ( ! empty( $meta[$key] ) ) : ?> |
| 2460 | <div class="misc-pub-section"> |
| 2461 | <?php echo $label ?> <strong><?php echo esc_html( $meta[$key] ); ?></strong> |
| 2462 | </div> |
| 2463 | <?php |
| 2464 | endif; |
| 2465 | endforeach; |
| 2466 | |
| 2467 | if ( ! empty( $meta['bitrate'] ) ) : ?> |
| 2468 | <div class="misc-pub-section"> |
| 2469 | <?php _e( 'Bitrate:' ); ?> <strong><?php |
| 2470 | echo $meta['bitrate'] / 1000, 'kb/s'; |
| 2471 | |
| 2472 | if ( ! empty( $meta['bitrate_mode'] ) ) |
| 2473 | echo ' ', strtoupper( $meta['bitrate_mode'] ); |
| 2474 | |
| 2475 | ?></strong> |
| 2476 | </div> |
| 2477 | <?php |
| 2478 | endif; |
| 2479 | |
| 2480 | $audio_fields = array( |
| 2481 | 'dataformat' => __( 'Audio Format:' ), |
| 2482 | 'codec' => __( 'Audio Codec:' ) |
| 2483 | ); |
| 2484 | |
| 2485 | foreach ( $audio_fields as $key => $label ): |
| 2486 | if ( ! empty( $meta['audio'][$key] ) ) : ?> |
| 2487 | <div class="misc-pub-section"> |
| 2488 | <?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][$key] ); ?></strong> |
| 2489 | </div> |
| 2490 | <?php |
| 2491 | endif; |
| 2492 | endforeach; |
| 2493 | |
| 2494 | endif; |
| 2495 | |
| 2496 | if ( $media_dims ) : ?> |