Summery Summery
Retrieve metadata from a video file’s ID3 tags
Syntax Syntax
Parameters Parameters
- $file
-
(Required) Path to file.
Return Return
(array|bool) Returns array of metadata, if found.
Source Source
File: wp-admin/includes/media.php
<input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" id="attachment_url" value="<?php echo esc_attr( $att_url ); ?>" /> <span class="copy-to-clipboard-container"> <button type="button" class="button copy-attachment-url edit-media" data-clipboard-target="#attachment_url"><?php _e( 'Copy URL' ); ?></button> <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> </span> </div> <div class="misc-pub-section misc-pub-filename"> <?php _e( 'File name:' ); ?> <strong><?php echo $filename; ?></strong> </div> <div class="misc-pub-section misc-pub-filetype"> <?php _e( 'File type:' ); ?> <strong> <?php if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) { echo esc_html( strtoupper( $matches[1] ) ); list( $mime_type ) = explode( '/', $post->post_mime_type ); if ( 'image' !== $mime_type && ! empty( $meta['mime_type'] ) ) { if ( "$mime_type/" . strtolower( $matches[1] ) !== $meta['mime_type'] ) { echo ' (' . $meta['mime_type'] . ')'; } } } else { echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) ); } ?> </strong> </div> <?php $file_size = false; if ( isset( $meta['filesize'] ) ) { $file_size = $meta['filesize']; } elseif ( file_exists( $file ) ) { $file_size = filesize( $file ); } if ( ! empty( $file_size ) ) { ?> <div class="misc-pub-section misc-pub-filesize"> <?php _e( 'File size:' ); ?> <strong><?php echo size_format( $file_size ); ?></strong> </div> <?php } if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) { $fields = array( 'length_formatted' => __( 'Length:' ), 'bitrate' => __( 'Bitrate:' ), ); /** * Filters the audio and video metadata fields to be shown in the publish meta box. * * The key for each item in the array should correspond to an attachment * metadata key, and the value should be the desired label. * * @since 3.7.0 * @since 4.9.0 Added the `$post` parameter. * * @param array $fields An array of the attachment metadata keys and labels. * @param WP_Post $post WP_Post object for the current attachment. */ $fields = apply_filters( 'media_submitbox_misc_sections', $fields, $post ); foreach ( $fields as $key => $label ) { if ( empty( $meta[ $key ] ) ) { continue; } ?> <div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class( $key ); ?>"> <?php echo $label; ?> <strong> <?php switch ( $key ) { case 'bitrate': echo round( $meta['bitrate'] / 1000 ) . 'kb/s'; if ( ! empty( $meta['bitrate_mode'] ) ) { echo ' ' . strtoupper( esc_html( $meta['bitrate_mode'] ) ); } break; default: echo esc_html( $meta[ $key ] ); break;
Advertisement
Changelog Changelog
Version | Description |
---|---|
3.6.0 | Introduced. |