wp_read_audio_metadata

Advertisement

Summery Summery

Retrieve metadata from an audio file’s ID3 tags.

Syntax Syntax

wp_read_audio_metadata( string $file )

Parameters Parameters

$file

(string) (Required) Path to file.

Return Return

(array|bool) Returns array of metadata, if found.

Source Source

File: wp-admin/includes/media.php

			'dataformat' => __( 'Audio Format:' ),
			'codec'      => __( 'Audio Codec:' ),
		);

		/**
		 * Filters the audio attachment 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.
		 */
		$audio_fields = apply_filters( 'audio_submitbox_misc_sections', $fields, $post );

		foreach ( $audio_fields as $key => $label ) {
			if ( empty( $meta['audio'][ $key ] ) ) {
				continue;
			}

			?>
			<div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class( $key ); ?>">
				<?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][ $key ] ); ?></strong>
			</div>
			<?php
		}
	}

	if ( $media_dims ) {
		?>
		<div class="misc-pub-section misc-pub-dimensions">
			<?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
		</div>
		<?php
	}

	if ( ! empty( $meta['original_image'] ) ) {
		?>
		<div class="misc-pub-section misc-pub-original-image">
			<?php _e( 'Original image:' ); ?>
			<a href="<?php echo esc_url( wp_get_original_image_url( $attachment_id ) ); ?>">
				<?php echo esc_html( wp_basename( wp_get_original_image_path( $attachment_id ) ) ); ?>
			</a>
		</div>
		<?php
	}

Advertisement

Changelog Changelog

Changelog
Version Description
3.6.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.