wp_add_id3_tag_data() - WordPress 函数参考中文文档

返回介绍

wp_add_id3_tag_data()

发布于 2017-09-11 字数2850 浏览 948 评论 0

wp_add_id3_tag_data( array $metadata,  array $data )

Parse ID3v2, ID3v1, and getID3 comments to extract usable data


描述


参数

$metadata

(array)
(Required)
An existing array with data

$data

(array)
(Required)
Data supplied by ID3 tags


源代码

File: wp-admin/includes/media.php

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 ( 'length' !== $key && ! empty( $list ) ) {
					$metadata[$key] = wp_kses_post( 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']
			);
		}
	}
}

更新日志

Version 描述
3.6.0 Introduced.

相关函数

Uses

  • wp-includes/kses.php:
    wp_kses_post()

Used By

  • wp-admin/includes/media.php:
    wp_read_video_metadata()
  • wp-admin/includes/media.php:
    wp_read_audio_metadata()

User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Codex

    Example

    
    $metadata = array();
    if ( ! class_exists( 'getID3' ) ) {
    	require( ABSPATH . WPINC . '/ID3/getid3.php' );
    }
    $id3 = new getID3();
    $data = $id3->analyze( $file );
    wp_add_id3_tag_data( $metadata, $data );
    

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!