Support » Fixing WordPress » Call to undefined function wp_read_audio_metadata()

Viewing 2 replies - 1 through 2 (of 2 total)
  • The wp_read_audio_metadata() function reads metadata from a specific file, but it is a heavy function so it, along with most of the other media uploader functions, are not included by default in a normal WP load process.

    The way WordPress works is that when you upload a file, these functions read all sorts of metadata from the files, and then save that metadata in the database. So if your file is uploaded through the normal media system, then an “attachment” post is created, and the metadata is already saved, attached to that post. You can use the normal post meta functions to retrieve and display it instead of reparsing the file every time.

    If you do need to parse a file not in the media system, then you need to manually include the WP administration functions (which includes the media functions, and others), by including the /wp-admin/includes/admin.php file.

    Note that wp_read_audio_metadata() does not take a URL, it takes a file path. It can only parse local files, not external URLs.

    Thanks a lot for your help and your precise answer !

    I finally find a way to get length of an external file. The trick is to download a very small part of the file, calculating the length of that, then extrapolate to the entire file. Here someone write a function to do that :

    To use this function in wordress I just had to change require_once('getid3/getid3.php')
    require_once( ABSPATH . 'wp-includes/ID3/getid3.php' )
    to include the getID3 library.

    But sure, this function is really slow, so I run it only one time when I save or update the post
    add_action( 'save_post', 'save_sound_length' );

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Call to undefined function wp_read_audio_metadata()’ is closed to new replies.