Filters the playlist output.
Description
Returning a non-empty value from the filter will short-circuit generation of the default playlist output, returning the passed value instead.
Parameters
$output
string- Playlist output. Default empty.
$attr
array- An array of shortcode attributes.
$instance
int- Unique numeric ID of this playlist shortcode instance.
Source
*/
How to display the album art from your audio files in a size other than ‘thumbnail’:
Sadly we can’t use responsive image sets with the default playlist / media player without completely rewriting the whole stack, which appears to involve jQuery, Backbone, undescore, a couple of mediaelement JS files, inlined JSON, and PHP templating. See /wp-includes/js/mediaelement/ and /wp-includes/media.php and media-template.php.
The next-best thing we can do is to use a higher-res image for the album artwork thumbnail. The JS files will read from the inlined JSON data, and by default will use the specified “thumb” property. That’s all we’re updating with the code below.
1. Add a custom attribute to your
playlist
shortcode to signify which registered image size you’d like to use. We’ll use acover_size="medium"
attribute.[playlist ids="121,82,84,43" cover_size="medium"]
2. Write your custom output using the post_playlist filter inside your functions.php file or elsewhere in your theme includes. Here I’ve removed any video playlist logic, see /wp-includes/media.php for the original.
$cover_size = $attr['cover_size'] ?? 'thumbnail';
(using the null coalescing operator, PHP >= 7.0)