Hi Blake, there is a quick & dirty way to get the image associated to a certain term (not the actually queried term) with this plugin: all associations are kept in an array, as a wp option, so you can get the entire array just using
$associations = get_option( 'taxonomy_image_plugin' );
Every array element has the term_id as key and the attachment id as value; so we can write a function to get the image associated to a specific term ID, like this one:
if ( !function_exists( 'get_term_image' ) ){
function get_term_image($args=array()) {
$defaults = array (
'term_id' => 0,
'size' => 'thumbnail',
'classes' => 'wp-attachment term-image'
);
$term_img=false;
// Parse incoming $args into an array and merge it with $defaults
$args = wp_parse_args( $args, $defaults );
// OPTIONAL: Declare each item in $args as its own variable i.e. $type, $before.
extract( $args, EXTR_SKIP );
if ( $term_id > 0) {
$associations = get_option( 'taxonomy_image_plugin' );//check tax images created by plugin Taxonomy Images
if ( is_array( $associations ) && count ($associations) ){
if ( isset($associations[$term_id]) ) {
$attachment_id=$associations[$term_id];
$term_img=wp_get_attachment_image( $attachment_id, $size, false, array( 'class' => $classes ) );
}
}
}
return $term_img;
}
}
Then you can get the html tag of the image associated with a term id, like this:
$args=(array(
"term_id" => $my_term_id,
"size" => "my_custom_size_or_one_of_small_medium_large",
"classes" => "class1 class2 class3"
));
$image = get_term_image($args);