FacetWP – HTML5 audio / mp3 player – display builder using an ACF file upload field

mgibbs189

{{gist file=”custom-hooks.php” lang=”php”}}
<?php

add_filter( ‘facetwp_builder_item_value’, function( $value, $item ) {
if ( ‘mp3-preview’ == $item[‘settings’][‘name’] ) {
if ( is_array( $value ) && ! empty( $value[‘url’] ) ) {
$src = $value[‘url’];
$value = ‘<audio controls>’;
$value .= ‘<source src=”‘ . $src . ‘” type=”audio/mpeg”>’;
$value .= ‘Your browser does not support the audio element.’;
$value .= ‘</audio>’;
}
}
return $value;
}, 10, 2 );

{{/gist}}