How to use Multimedia Metadata in WordPress

Most digital music, images and video contain metadata. This metadata (with a bit of code) can be used to make dynamic pages and posts. Information stored on the digital media (‘Tags’) can be copied by WordPress and inserted into your post or page.

And the best thing is, you don’t have to type a thing (other than the initial bit of code to make it work)…

For non WordPress users, I have another article on getID3. It explains a bit more about how to use it, outside of the WordPress framework.

Topics on This Page:

Multimedia and getID3

What is getID3?

getID3 is used in WordPress to extract the metadata from the multimedia files. It’s an open-source program distributed under the GNU General Public License (see the website getid3.org for more information).

Download getID3:

If you’re using WordPress, getID3 is already included in the core WordPress files, so you don’t need to download getID3.

Where are the getID3 Files?

The files are located at:

wordpress\wp-includes\ID3

In other words… Your WordPress site folder which would be similar to either of these examples:

htdocs\example.com\wp-includes\ID3

public_html\example.com\wp-includes\ID3

How do I install getID3 in WordPress?

To get ‘getID3’ to work in WordPress, you will need to tell WordPress to run the ‘media.php’ file. Otherwise, none of the WordPress metadata functions will work, and you may receive a ‘fatal error’ message like the one in the image below.

WordPress Fatal Error
WordPress Fatal Error

To run the ‘media.php’ file, type the following in your ‘functions.php’ file (or in the template file your using) and save the file:

require_once(ABSPATH . ‘wp-admin/includes/media.php’);

How do I Extract Metadata?

To extract and display the metadata, you will need a WordPress function(s) and some PHP code.

Here are some example WordPress functions that can manipulate the multimedia metadata:

A complete list of WordPress metadata functions can be found in the WordPress Reference by typing in metadata in the search box.

getID3 Example:

Here is an example where getID3 has been used to build a web page that displays a list of songs on a music player. getID3 has been used to automatically populate the fields in the music player.

Using getID3 to Retrieve Metadata and Insert it in a Music Player

When you add a song to the page, getID3 pulls out the metadata from the music file, and places it in the music player alongside the song. It’s great, you don’t have to type a thing!

Here’s a link to a working example:

Marie – My Songs (works in progress)

I have another article that explains more about how to use getID3 for non-WordPress users. It may also help you understand how getID3 works.

Exit mobile version