I'm trying to stuff a variable called
$work_ids with the ID of any attached MP3 files for use in a custom player (based on MediaElement.js if that matters). The library contains WAV and other versions of each file which we don't want to stream, so I'm trying to filter those files, and only present MP3s in the variable (there can be more than one, that's fine). Here's what I've tried (and failed):
I thought this would get me rolling by itself:
$work_ids = get_attached_media( 'audio/mp3', $post->ID );
Nope, that returns nothing usable to the script.
So then I thought, maybe I need to throw in some commas to handle multiple MP3s returned, but nope, that's not the case... this works no better:
$work_ids = join( ',', wp_list_pluck( get_attached_media( 'audio/mp3' ), 'ID' ) );
Next I figured it was the ID not banging, so I changed the reference to something more explicit:
$work_ids = join( ',', wp_list_pluck( get_attached_media( 'audio/mp3' ), $post->ID ) );
I put these right below the loop, where I draw a conventional WP playlist object
[playlist ids=""] via shortcode. This part of the script actually works fine, when I insert a fixed ID, or use another variable floating around (which unfortunately includes WAVs!), like
$submission_attachment_ids, for whatever that's worth (just confirms my template CAN work with a variable I suppose). By itself, that variable, or any containing media attachment IDs, calls and runs the custom player and works fine.
How can I filter off the WAVs, and return only MP3s as IDs? I just want to filter filetype.