Replace taxonomy term with an image in a custom loop

This is a quick and easy solution if you only have two terms and don’t need a way to change those pictures in the backend.

It assumes that inside your theme you have a folder “term_imgs” with *.png files names according to the slugs of your terms.

$terms = get_the_terms( $post->ID, 'Tax1' );
$out = array();
if ( $terms && ! is_wp_error( $terms ) ) {
    if ( !empty( $terms ) ) {
      foreach ( $terms as $term ) {
        $out[] = '<a href="'.get_term_link( $term->slug, 'Tax1' ) .'"><img alt="'.$term->name.'" src="'.get_template_directory_uri().'/term_imgs/'.$term->slug.'.png"></a>';
      }
      echo implode(',', $out );
    }
}

You can call this folder however you want, just change the according piece of code, e.g.

$out[] = '<a href="'.get_term_link( $term->slug, 'Tax1' ) .'"><img alt="'.$term->name.'" src="'.get_template_directory_uri().'/other_folder/'.$term->slug.'.jpg"></a>';