admin管理员组文章数量:1332377
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
1 Answer
Reset to default 9wp_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 ) );
本文标签: uploadsIs wpreadaudiometadata() function deprecated
版权声明:本文标题:uploads - Is wp_read_audio_metadata() function deprecated? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742306232a2449972.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论