]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/media.php
Wordpress 3.6
[autoinstalls/wordpress.git] / wp-admin / includes / media.php
index a8751f12313879ed6e57e251ef99422d3c38b91c..b8cc09817948f908aba17158487aef8d470166d3 100644 (file)
@@ -224,8 +224,60 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override
        $title = $name;
        $content = '';
 
+       if ( preg_match( '#^audio#', $type ) ) {
+               $meta = wp_read_audio_metadata( $file );
+
+               if ( ! empty( $meta['title'] ) )
+                       $title = $meta['title'];
+
+               $content = '';
+
+               if ( ! empty( $title ) ) {
+
+                       if ( ! empty( $meta['album'] ) && ! empty( $meta['artist'] ) ) {
+                               /* translators: 1: audio track title, 2: album title, 3: artist name */
+                               $content .= sprintf( __( '"%1$s" from %2$s by %3$s.' ), $title, $meta['album'], $meta['artist'] );
+                       } else if ( ! empty( $meta['album'] ) ) {
+                               /* translators: 1: audio track title, 2: album title */
+                               $content .= sprintf( __( '"%1$s" from %2$s.' ), $title, $meta['album'] );
+                       } else if ( ! empty( $meta['artist'] ) ) {
+                               /* translators: 1: audio track title, 2: artist name */
+                               $content .= sprintf( __( '"%1$s" by %2$s.' ), $title, $meta['artist'] );
+                       } else {
+                               $content .= sprintf( __( '"%s".' ), $title );
+                       }
+
+               } else if ( ! empty( $meta['album'] ) ) {
+
+                       if ( ! empty( $meta['artist'] ) ) {
+                               /* translators: 1: audio album title, 2: artist name */
+                               $content .= sprintf( __( '%1$s by %2$s.' ), $meta['album'], $meta['artist'] );
+                       } else {
+                               $content .= $meta['album'] . '.';
+                       }
+
+               } else if ( ! empty( $meta['artist'] ) ) {
+
+                       $content .= $meta['artist'] . '.';
+
+               }
+
+               if ( ! empty( $meta['year'] ) )
+                       $content .= ' ' . sprintf( __( 'Released: %d.' ), $meta['year'] );
+
+               if ( ! empty( $meta['track_number'] ) ) {
+                       $track_number = explode( '/', $meta['track_number'] );
+                       if ( isset( $track_number[1] ) )
+                               $content .= ' ' . sprintf( __( 'Track %1$s of %2$s.' ), number_format_i18n( $track_number[0] ), number_format_i18n( $track_number[1] ) );
+                       else
+                               $content .= ' ' . sprintf( __( 'Track %1$s.' ), number_format_i18n( $track_number[0] ) );
+               }
+
+               if ( ! empty( $meta['genre'] ) )
+                       $content .= ' ' . sprintf( __( 'Genre: %s.' ), $meta['genre'] );
+
        // use image exif/iptc data for title and caption defaults if possible
-       if ( $image_meta = @wp_read_image_metadata($file) ) {
+       } elseif ( $image_meta = @wp_read_image_metadata( $file ) ) {
                if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
                        $title = $image_meta['title'];
                if ( trim( $image_meta['caption'] ) )
@@ -340,7 +392,6 @@ wp_enqueue_style( 'ie' );
 <script type="text/javascript">
 //<![CDATA[
 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
-var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time(); ?>'};
 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
 isRtl = <?php echo (int) is_rtl(); ?>;
 //]]>
@@ -393,7 +444,7 @@ function media_buttons($editor_id = 'content') {
 
        $img = '<span class="wp-media-buttons-icon"></span> ';
 
-       echo '<a href="#" class="button insert-media add_media" data-editor="' . esc_attr( $editor_id ) . '" title="' . esc_attr__( 'Add Media' ) . '">' . $img . __( 'Add Media' ) . '</a>';
+       echo '<a href="#" id="insert-media-button" class="button insert-media add_media" data-editor="' . esc_attr( $editor_id ) . '" title="' . esc_attr__( 'Add Media' ) . '">' . $img . __( 'Add Media' ) . '</a>';
 
        // Don't use this filter. Want to add a button? Use the media_buttons action.
        $legacy_filter = apply_filters('media_buttons_context', ''); // deprecated
@@ -445,9 +496,8 @@ function media_upload_form_handler() {
 
        if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
                $post = $_post = get_post($attachment_id, ARRAY_A);
-               $post_type_object = get_post_type_object( $post[ 'post_type' ] );
 
-               if ( !current_user_can( $post_type_object->cap->edit_post, $attachment_id ) )
+               if ( !current_user_can( 'edit_post', $attachment_id ) )
                        continue;
 
                if ( isset($attachment['post_content']) )
@@ -467,11 +517,11 @@ function media_upload_form_handler() {
                $post = apply_filters('attachment_fields_to_save', $post, $attachment);
 
                if ( isset($attachment['image_alt']) ) {
-                       $image_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
-                       if ( $image_alt != stripslashes($attachment['image_alt']) ) {
-                               $image_alt = wp_strip_all_tags( stripslashes($attachment['image_alt']), true );
+                       $image_alt = wp_unslash( $attachment['image_alt'] );
+                       if ( $image_alt != get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ) {
+                               $image_alt = wp_strip_all_tags( $image_alt, true );
                                // update_meta expects slashed
-                               update_post_meta( $attachment_id, '_wp_attachment_image_alt', addslashes($image_alt) );
+                               update_post_meta( $attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
                        }
                }
 
@@ -501,7 +551,7 @@ function media_upload_form_handler() {
        }
 
        if ( isset($send_id) ) {
-               $attachment = stripslashes_deep( $_POST['attachments'][$send_id] );
+               $attachment = wp_unslash( $_POST['attachments'][$send_id] );
 
                $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
                if ( !empty($attachment['url']) ) {
@@ -546,7 +596,7 @@ function wp_media_upload_handler() {
                        $src = "http://$src";
 
                if ( isset( $_POST['media_type'] ) && 'image' != $_POST['media_type'] ) {
-                       $title = esc_html( stripslashes( $_POST['title'] ) );
+                       $title = esc_html( wp_unslash( $_POST['title'] ) );
                        if ( empty( $title ) )
                                $title = esc_html( basename( $src ) );
 
@@ -561,9 +611,9 @@ function wp_media_upload_handler() {
                        $html = apply_filters( $type . '_send_to_editor_url', $html, esc_url_raw( $src ), $title );
                } else {
                        $align = '';
-                       $alt = esc_attr( stripslashes( $_POST['alt'] ) );
+                       $alt = esc_attr( wp_unslash( $_POST['alt'] ) );
                        if ( isset($_POST['align']) ) {
-                               $align = esc_attr( stripslashes( $_POST['align'] ) );
+                               $align = esc_attr( wp_unslash( $_POST['align'] ) );
                                $class = " class='align$align'";
                        }
                        if ( !empty($src) )
@@ -1108,7 +1158,7 @@ function get_media_item( $attachment_id, $args = null ) {
        }
 
        $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
-       $display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : '';
+       $display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60, '&hellip;' ) . "</span></div>" : '';
 
        $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) );
        $order = '';
@@ -1127,7 +1177,7 @@ function get_media_item( $attachment_id, $args = null ) {
 
        $media_dims = '';
        $meta = wp_get_attachment_metadata( $post->ID );
-       if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
+       if ( isset( $meta['width'], $meta['height'] ) )
                $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
        $media_dims = apply_filters( 'media_meta', $media_dims, $post );
 
@@ -1452,7 +1502,7 @@ function media_upload_form( $errors = null ) {
        global $type, $tab, $pagenow, $is_IE, $is_opera;
 
        if ( ! _device_can_upload() ) {
-               echo '<p>' . __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="http://wordpress.org/extend/mobile/">native app for your device</a> instead.') . '</p>';
+               echo '<p>' . sprintf( __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'http://wordpress.org/mobile/' ) . '</p>';
                return;
        }
 
@@ -1602,7 +1652,7 @@ function media_upload_type_form($type = 'file', $errors = null, $id = null) {
                $form_class .= ' html-uploader';
 ?>
 
-<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
 <?php submit_button( '', 'hidden', 'save', false ); ?>
 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
 <?php wp_nonce_field('media-form'); ?>
@@ -1667,7 +1717,7 @@ function media_upload_type_url_form($type = null, $errors = null, $id = null) {
                $form_class .= ' html-uploader';
 ?>
 
-<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
 <?php wp_nonce_field('media-form'); ?>
 
@@ -1818,7 +1868,7 @@ jQuery(function($){
 <a href="#" id="desc"><?php _e('Descending'); ?></a> |
 <a href="#" id="clear"><?php _ex('Clear', 'verb'); ?></a>
 </div>
-<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="gallery-form">
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="gallery-form">
 <?php wp_nonce_field('media-form'); ?>
 <?php //media_upload_form( $errors ); ?>
 <table class="widefat" cellspacing="0">
@@ -2058,7 +2108,7 @@ foreach ($arc_result as $arc_row) {
 </div>
 </form>
 
-<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="library-form">
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="library-form">
 
 <?php wp_nonce_field('media-form'); ?>
 <?php //media_upload_form( $errors ); ?>
@@ -2270,9 +2320,7 @@ function multisite_over_quota_message() {
  *
  * @since 3.5.0
  */
-function edit_form_image_editor() {
-       $post = get_post();
-
+function edit_form_image_editor( $post ) {
        $open = isset( $_GET['image-editor'] );
        if ( $open )
                require_once ABSPATH . 'wp-admin/includes/image-edit.php';
@@ -2285,8 +2333,9 @@ function edit_form_image_editor() {
        $title = esc_attr( $post->post_title );
        $alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
 
-       $att_url = wp_get_attachment_url( $post->ID );
-
+       $att_url = wp_get_attachment_url( $post->ID ); ?>
+       <div class="wp_attachment_holder">
+       <?php
        if ( wp_attachment_is_image( $post->ID ) ) :
                $image_edit_button = '';
                if ( wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) {
@@ -2294,7 +2343,7 @@ function edit_form_image_editor() {
                        $image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <span class='spinner'></span>";
                }
        ?>
-       <div class="wp_attachment_holder">
+
                <div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div>
 
                <div<?php if ( $open ) echo ' style="display:none"'; ?> class="wp_attachment_image" id="media-head-<?php echo $attachment_id; ?>">
@@ -2304,10 +2353,34 @@ function edit_form_image_editor() {
                <div<?php if ( ! $open ) echo ' style="display:none"'; ?> class="image-editor" id="image-editor-<?php echo $attachment_id; ?>">
                        <?php if ( $open ) wp_image_editor( $attachment_id ); ?>
                </div>
-       </div>
-       <?php endif; ?>
+       <?php
+       elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'audio/' ) ):
+
+               echo wp_audio_shortcode( array( 'src' => $att_url ) );
+
+       elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'video/' ) ):
+
+               $meta = wp_get_attachment_metadata( $attachment_id );
+               $w = ! empty( $meta['width'] ) ? min( $meta['width'], 600 ) : 0;
+               $h = 0;
+               if ( ! empty( $meta['height'] ) )
+                       $h = $meta['height'];
+               if ( $h && $w < $meta['width'] )
+                       $h = round( ( $meta['height'] * $w ) / $meta['width'] );
+
+               $attr = array( 'src' => $att_url );
 
-       <div class="wp_attachment_details">
+               if ( ! empty( $meta['width' ] ) )
+                       $attr['width'] = $w;
+
+               if ( ! empty( $meta['height'] ) )
+                       $attr['height'] = $h;
+
+               echo wp_video_shortcode( $attr );
+
+       endif; ?>
+       </div>
+       <div class="wp_attachment_details edit-form-section">
                <p>
                        <label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
                        <textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
@@ -2321,7 +2394,7 @@ function edit_form_image_editor() {
        <?php endif; ?>
 
        <?php
-               $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' );
+               $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
                $editor_args = array(
                        'textarea_name' => 'content',
                        'textarea_rows' => 5,
@@ -2349,11 +2422,11 @@ function edit_form_image_editor() {
 function attachment_submitbox_metadata() {
        $post = get_post();
 
-       $filename = esc_html( basename( $post->guid ) );
+       $filename = esc_html( wp_basename( $post->guid ) );
 
        $media_dims = '';
        $meta = wp_get_attachment_metadata( $post->ID );
-       if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
+       if ( isset( $meta['width'], $meta['height'] ) )
                $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
        $media_dims = apply_filters( 'media_meta', $media_dims, $post );
 
@@ -2375,7 +2448,55 @@ function attachment_submitbox_metadata() {
                ?></strong>
        </div>
 
-<?php if ( $media_dims ) : ?>
+<?php
+       if ( preg_match( '#^audio|video#', $post->post_mime_type ) ):
+
+               $fields = array(
+                       'mime_type' => __( 'Mime-type:' ),
+                       'year' => __( 'Year:' ),
+                       'genre' => __( 'Genre:' ),
+                       'length_formatted' => __( 'Length:' ),
+               );
+
+               foreach ( $fields as $key => $label ):
+                       if ( ! empty( $meta[$key] ) ) : ?>
+               <div class="misc-pub-section">
+                       <?php echo $label ?> <strong><?php echo esc_html( $meta[$key] ); ?></strong>
+               </div>
+       <?php
+                       endif;
+               endforeach;
+
+               if ( ! empty( $meta['bitrate'] ) ) : ?>
+               <div class="misc-pub-section">
+                       <?php _e( 'Bitrate:' ); ?> <strong><?php
+                               echo round( $meta['bitrate'] / 1000 ), 'kb/s';
+
+                               if ( ! empty( $meta['bitrate_mode'] ) )
+                                       echo ' ', strtoupper( $meta['bitrate_mode'] );
+
+                       ?></strong>
+               </div>
+       <?php
+               endif;
+
+               $audio_fields = array(
+                       'dataformat' => __( 'Audio Format:' ),
+                       'codec' => __( 'Audio Codec:' )
+               );
+
+               foreach ( $audio_fields as $key => $label ):
+                       if ( ! empty( $meta['audio'][$key] ) ) : ?>
+               <div class="misc-pub-section">
+                       <?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][$key] ); ?></strong>
+               </div>
+       <?php
+                       endif;
+               endforeach;
+
+       endif;
+
+       if ( $media_dims ) : ?>
        <div class="misc-pub-section">
                <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
        </div>
@@ -2397,3 +2518,142 @@ add_filter( 'media_upload_gallery', 'media_upload_gallery' );
 add_filter( 'media_upload_library', 'media_upload_library' );
 
 add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata' );
+
+/**
+ * Parse ID3v2, ID3v1, and getID3 comments to extract usable data
+ *
+ * @since 3.6.0
+ *
+ * @param array $metadata An existing array with data
+ * @param array $data Data supplied by ID3 tags
+ */
+function wp_add_id3_tag_data( &$metadata, $data ) {
+       foreach ( array( 'id3v2', 'id3v1' ) as $version ) {
+               if ( ! empty( $data[$version]['comments'] ) ) {
+                       foreach ( $data[$version]['comments'] as $key => $list ) {
+                               if ( ! empty( $list ) ) {
+                                       $metadata[$key] = reset( $list );
+                                       // fix bug in byte stream analysis
+                                       if ( 'terms_of_use' === $key && 0 === strpos( $metadata[$key], 'yright notice.' ) )
+                                               $metadata[$key] = 'Cop' . $metadata[$key];
+                               }
+                       }
+                       break;
+               }
+       }
+
+       if ( ! empty( $data['id3v2']['APIC'] ) ) {
+               $image = reset( $data['id3v2']['APIC']);
+               if ( ! empty( $image['data'] ) ) {
+                       $metadata['image'] = array(
+                               'data' => $image['data'],
+                               'mime' => $image['image_mime'],
+                               'width' => $image['image_width'],
+                               'height' => $image['image_height']
+                       );
+               }
+       } elseif ( ! empty( $data['comments']['picture'] ) ) {
+               $image = reset( $data['comments']['picture'] );
+               if ( ! empty( $image['data'] ) ) {
+                       $metadata['image'] = array(
+                               'data' => $image['data'],
+                               'mime' => $image['image_mime']
+                       );
+               }
+       }
+}
+
+/**
+ * Retrieve metadata from a video file's ID3 tags
+ *
+ * @since 3.6.0
+ *
+ * @param string $file Path to file.
+ * @return array|boolean Returns array of metadata, if found.
+ */
+function wp_read_video_metadata( $file ) {
+       if ( ! file_exists( $file ) )
+               return false;
+
+       $metadata = array();
+
+       if ( ! class_exists( 'getID3' ) )
+               require( ABSPATH . WPINC . '/ID3/getid3.php' );
+       $id3 = new getID3();
+       $data = $id3->analyze( $file );
+
+       if ( isset( $data['video']['lossless'] ) )
+               $metadata['lossless'] = $data['video']['lossless'];
+       if ( ! empty( $data['video']['bitrate'] ) )
+               $metadata['bitrate'] = (int) $data['video']['bitrate'];
+       if ( ! empty( $data['video']['bitrate_mode'] ) )
+               $metadata['bitrate_mode'] = $data['video']['bitrate_mode'];
+       if ( ! empty( $data['filesize'] ) )
+               $metadata['filesize'] = (int) $data['filesize'];
+       if ( ! empty( $data['mime_type'] ) )
+               $metadata['mime_type'] = $data['mime_type'];
+       if ( ! empty( $data['playtime_seconds'] ) )
+               $metadata['length'] = (int) ceil( $data['playtime_seconds'] );
+       if ( ! empty( $data['playtime_string'] ) )
+               $metadata['length_formatted'] = $data['playtime_string'];
+       if ( ! empty( $data['video']['resolution_x'] ) )
+               $metadata['width'] = (int) $data['video']['resolution_x'];
+       if ( ! empty( $data['video']['resolution_y'] ) )
+               $metadata['height'] = (int) $data['video']['resolution_y'];
+       if ( ! empty( $data['fileformat'] ) )
+               $metadata['fileformat'] = $data['fileformat'];
+       if ( ! empty( $data['video']['dataformat'] ) )
+               $metadata['dataformat'] = $data['video']['dataformat'];
+       if ( ! empty( $data['video']['encoder'] ) )
+               $metadata['encoder'] = $data['video']['encoder'];
+       if ( ! empty( $data['video']['codec'] ) )
+               $metadata['codec'] = $data['video']['codec'];
+
+       if ( ! empty( $data['audio'] ) ) {
+               unset( $data['audio']['streams'] );
+               $metadata['audio'] = $data['audio'];
+       }
+
+       wp_add_id3_tag_data( $metadata, $data );
+
+       return $metadata;
+}
+
+/**
+ * Retrieve metadata from a audio file's ID3 tags
+ *
+ * @since 3.6.0
+ *
+ * @param string $file Path to file.
+ * @return array|boolean Returns array of metadata, if found.
+ */
+function wp_read_audio_metadata( $file ) {
+       if ( ! file_exists( $file ) )
+               return false;
+       $metadata = array();
+
+       if ( ! class_exists( 'getID3' ) )
+               require( ABSPATH . WPINC . '/ID3/getid3.php' );
+       $id3 = new getID3();
+       $data = $id3->analyze( $file );
+
+       if ( ! empty( $data['audio'] ) ) {
+               unset( $data['audio']['streams'] );
+               $metadata = $data['audio'];
+       }
+
+       if ( ! empty( $data['fileformat'] ) )
+               $metadata['fileformat'] = $data['fileformat'];
+       if ( ! empty( $data['filesize'] ) )
+               $metadata['filesize'] = (int) $data['filesize'];
+       if ( ! empty( $data['mime_type'] ) )
+               $metadata['mime_type'] = $data['mime_type'];
+       if ( ! empty( $data['playtime_seconds'] ) )
+               $metadata['length'] = (int) ceil( $data['playtime_seconds'] );
+       if ( ! empty( $data['playtime_string'] ) )
+               $metadata['length_formatted'] = $data['playtime_string'];
+
+       wp_add_id3_tag_data( $metadata, $data );
+
+       return $metadata;
+}