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