The following code is partialy taken from the plugin Taxonomy Images and it’s working:
function get_taxonomy_image( $atts ) {
$atts = shortcode_atts( array(
'image_size' => 'thumbnail',
'id' => '',
), $atts );
if( ! empty( $atts['id'] ) ) {
$term = get_term( $atts['id'] );
$related_id = 0;
if ( isset( $term->term_taxonomy_id ) ) {
$related_id = (int) $term->term_taxonomy_id;
}
$attachment_id = 0;
$associations = get_option( 'taxonomy_image_plugin' );
if ( isset( $associations[ $related_id ] ) ) {
$attachment_id = (int) $associations[ $related_id ];
}
$imgsrc = wp_get_attachment_image_src( $attachment_id, $atts['image_size'] );
return $imgsrc[0];
}
return 'no-id-set';
}
add_shortcode( 'sagaio-term-image', 'get_taxonomy_image' );