Set default values for attachment meta and ID3 data when preparing for JS to avoid errors in rendering templates. props ericmann for the initial patch. fixes #29013.

Built from https://develop.svn.wordpress.org/trunk@29281


git-svn-id: http://core.svn.wordpress.org/trunk@29063 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí 2014-07-24 18:04:18 +00:00
parent 448275cce4
commit 6f44e96d70
2 changed files with 4 additions and 1 deletions

View File

@ -325,7 +325,7 @@ function wp_print_media_templates() {
<div class="file-length"><strong><?php _e( 'Length:' ); ?></strong> {{ data.fileLength }}</div>
<# } #>
<# if ( 'audio' === data.type && data.meta && data.meta.bitrate ) { #>
<# if ( 'audio' === data.type && data.meta.bitrate ) { #>
<div class="bitrate">
<strong><?php _e( 'Bitrate:' ); ?></strong> {{ Math.round( data.meta.bitrate / 1000 ) }}kb/s
<# if ( data.meta.bitrate_mode ) { #>

View File

@ -2628,6 +2628,7 @@ function wp_prepare_attachment_for_js( $attachment ) {
'edit' => false
),
'editLink' => false,
'meta' => false,
);
$author = new WP_User( $attachment->post_author );
@ -2725,6 +2726,8 @@ function wp_prepare_attachment_for_js( $attachment ) {
$response['meta'] = array();
foreach ( wp_get_attachment_id3_keys( $attachment, 'js' ) as $key => $label ) {
$response['meta'][ $key ] = false;
if ( ! empty( $meta[ $key ] ) ) {
$response['meta'][ $key ] = $meta[ $key ];
}