How to display more audio file ID3 tags in WordPress

So, two months after posting my question I finally found an answer! It is based on code I found here on WordPress StackExchange that was used in an answer to a different question. 🙂

I just added the following to the top of my custom playlist plugin (which is also based on an code from an answer here):

// Add id3 tags as meta keys
add_filter( 'wp_get_attachment_id3_keys', $callback_id3 = function( $fields ) 
{
    $fields['title'] = 'Track Title';
    $fields['comments'] = 'Comments';
    $fields['filesize'] = 'File Size';
    return $fields;
} );

And then in the playlist template I just added {{ data.meta.title }}, {{ data.meta.comments}}, and {{ data.meta.filesize}} where I wanted them to be shown.

The reason I added title is because the default {{ data.title }} shows the filename without the extension instead of the the actual track title written in the ID3 tags, and {{ data.meta.title }} gave me the actual ID3 tag title.

Worth noting is that I had a hard time with the comments tag because everywhere I looked at ID3 comment tags (documentations, wp metadata array, etc) it was written singular (just comment). But then I checked getID3 and found that it uses the plural form, comments. So adding the s made my ID3 comments show at last.

I am still trying to figure out how to get the filesize to show in a more readable manner (it seems to be a matter of trial and error with me). If I can’t figure it out I’ll ask here.

Thanks to the community here for posting all the different answers and code samples – I wouldn’t have been able to figure this out without the resources here. So grateful 🙂