uploads - Is wp_read_audio_metadata() function deprecated?

I am trying to use the function wp_read_audio_metadata() to read the metadata for an mp3 file uploaded to a post using a

I am trying to use the function wp_read_audio_metadata() to read the metadata for an mp3 file uploaded to a post using acf's file field.

Below is my code:

<?php 
$audio_file = get_field('archive_audio_file'); 
$audio_file_id = $audio_file['id'];
$audio_file_path = get_attached_file( $audio_file_id);
var_dump(wp_read_audio_metadata($audio_file_path));
?>

When using that code I receive this error on the front end:

Fatal error: Call to undefined function wp_read_audio_metadata()

Am I using the code incorrectly? or this function is deprecated? because I couldn't find it in wp-includes/media.php

I am trying to use the function wp_read_audio_metadata() to read the metadata for an mp3 file uploaded to a post using acf's file field.

Below is my code:

<?php 
$audio_file = get_field('archive_audio_file'); 
$audio_file_id = $audio_file['id'];
$audio_file_path = get_attached_file( $audio_file_id);
var_dump(wp_read_audio_metadata($audio_file_path));
?>

When using that code I receive this error on the front end:

Fatal error: Call to undefined function wp_read_audio_metadata()

Am I using the code incorrectly? or this function is deprecated? because I couldn't find it in wp-includes/media.php

Share Improve this question edited Jan 26, 2017 at 21:40 Arsalan Mithani 5534 silver badges15 bronze badges asked Jan 26, 2017 at 21:15 CelsoCelso 2011 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 9

wp_read_audio_metadata() is not deprecated. It's located in /wp-admin/includes/media.php, which is not loaded on the front end, hence the error your're getting.

You are using the function correctly. You can make wp_read_audio_metadata() available by including wp-admin/includes/media.php before calling the function, e.g.:

require_once( ABSPATH . 'wp-admin/includes/media.php' );
$audio_file_path = get_attached_file( 1821 ); // example attachment ID
var_dump( wp_read_audio_metadata( $audio_file_path ) );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742306232a4418995.html

相关推荐

  • uploads - Is wp_read_audio_metadata() function deprecated?

    I am trying to use the function wp_read_audio_metadata() to read the metadata for an mp3 file uploaded to a post using a

    16小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信