Changeset 23979
- Timestamp:
- 04/12/2013 10:27:24 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r23923 r23979 225 225 $content = ''; 226 226 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 227 279 // use image exif/iptc data for title and caption defaults if possible 228 if ( $image_meta = @wp_read_image_metadata($file) ) {280 } elseif ( $image_meta = @wp_read_image_metadata( $file ) ) { 229 281 if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) 230 282 $title = $image_meta['title']; … … 2314 2366 2315 2367 $meta = wp_get_attachment_metadata( $attachment_id ); 2368 $w = ! empty( $meta['width'] ) ? min( $meta['width'], 600 ) : 0; 2369 $h = 0; 2370 if ( ! empty( $meta['height'] ) ) 2371 $h = $meta['height']; 2372 if ( $h && $w < $meta['width'] ) 2373 $h = round( ( $meta['height'] * $w ) / $meta['width'] ); 2374 2316 2375 $shortcode = sprintf( '[video src="%s"%s%s]', 2317 2376 $att_url, 2318 empty( $meta['width'] ) ? '' : sprintf( ' width="%d"', $ meta['width']),2319 empty( $meta['height'] ) ? '' : sprintf( ' height="%d"', $ meta['height'])2377 empty( $meta['width'] ) ? '' : sprintf( ' width="%d"', $w ), 2378 empty( $meta['height'] ) ? '' : sprintf( ' height="%d"', $h ) 2320 2379 ); 2321 2380 echo do_shortcode( $shortcode ); … … 2391 2450 </div> 2392 2451 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 ) : ?> 2394 2501 <div class="misc-pub-section"> 2395 2502 <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
Note: See TracChangeset
for help on using the changeset viewer.