<?php
/** adds images to the labels in an fselect **/
add_filter( 'facetwp_facet_display_value', function( $label, $params ) {
if ( 'my_facet_name' == $params['facet']['name'] ) { // Replace "my_facet_name" with the name of your facet
$term_id = $params["row"]["term_id"]; // get term_id
$img = // lookup image for the term_id to create an img tag for output
$img = esc_html( $img ); // esc_html is needed for fselects to have image html in them, otherwise the html is stripped from the display
$label = $img . $label; // prepends image to label, use $label = $img; if you want to only display image in label
}
return $label;
}, 10, 2 );