The growing library of 300+ ready-to-use templates that work with all WordPress themes including Astra, Hello,...
Associate images from your media library to categories, tags and custom taxonomies.
Taxonomy Images is a WordPress plugin that allows you to associate images with taxonomy terms, such as categories and tags. It provides filters that can be used in your theme to display these images in various templates like category.php and tag.php. The plugin is designed for developers who want to enhance the visual representation of taxonomy archives on their sites.
The plugin supports displaying a single image for each term and allows for customization of the image's HTML attributes. You can also retrieve the image ID, object, or URL using specific filters, making it flexible for different use cases.
Best for: This plugin suits developers looking to enhance taxonomy term displays with images on WordPress sites.
What it does well
Where it falls short
Taxonomy Images is a useful tool for developers wanting to visually enrich taxonomy archives, though it requires technical knowledge to implement effectively.
Ben Huson's own description of Taxonomy Images, lightly tidied.
There are a few filters that you can use in your theme to display the image associations created by this plugin. Please read below for detailed information.
The following filter will display the image associated with the term asked for in the query string of the URL. This filter only works in views that naturally use templates like category.php, tag.php, taxonomy.php and all of their derivatives. Please read about template hierarchy for more information about these templates. The simplest use of this filter looks like:
print apply_filters( 'taxonomy-images-queried-term-image', '' );
This code will generate and print an image tag. It’s output can be modifed by passing an optional third parameter to apply_filters(). This parameter is an array and the following keys may be set:
after (string) – Text to append to the image’s HTML.
attr (array) – Key / value pairs representing the attributes of the img tag. Available options include: alt, class, src and title. This array will be passed as the fourth parameter to WordPress core function wp_get_attachment_image() without modification.
before (string) – Text to prepend to the image’s HTML.
image_size (string) – May be any image size registered with WordPress. If no image size is specified, ‘thumbnail’ will be used as a default value. In the event that an unregistered size is specified, this filter will return an empty string.
Here’s an example of what a fully customized version of this filter might look like:
print apply_filters( 'taxonomy-images-queried-term-image', '', array(
'attr' => array(
'alt' => 'Custom alternative text',
'class' => 'my-class-list bunnies turtles',
'src' => 'this-is-where-the-image-lives.png',
'title' => 'Custom Title',
),
'before' => '<div id="my-custom-div">',
'after' => '</div>',
'image_size' => 'medium'
) );
If you just need to get the database ID for the image, you may want to use:
$image_id = apply_filters( 'taxonomy-images-queried-term-image-id', 0 );
If you need to get the full object of the image, you may want to use:
$image = apply_filters( 'taxonomy-images-queried-term-image-object', '' );
If you need to get the URL to the image, you may want to use the following:
$image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '' );
Other plugins for libraries and archives.
The growing library of 300+ ready-to-use templates that work with all WordPress themes including Astra, Hello,...
Securely upload SVG files to your media library, with built-in sanitization and advanced features for styling...
Easily replace any attached image/file by simply uploading a new file in the Media Library edit view - a real...
HappyAddons packs Header Footer Builder, Megamenu, Single Post, Archive Page, & 500+ Ready Templates into...
CMB2 is a metabox, custom fields, and forms library for WordPress that will blow your mind.
The best WordPress templates, pattern, and layout library with 1,000+ designs built for the Gutenberg block ed...