• Development
  • Management
  • Case Studies
  • Testimonials
  • Get Started
  • Home
  • Development
  • Management
  • Testimonials
  • Case Studies
  • Get Started

Home / Plugins / Genesis Taxonomy Images / gtaxi_get_taxonomy_image()

gtaxi_get_taxonomy_image( array $opts = array() )

Retrieves the image assigned to a term via the Genesis Taxonomy Images plugin.

Parameters

$opts

(array)(Optional) The array of options telling gtaxi_get_taxonomy_image() what to retrieve.

The array can contain any of the following:

format

(string) The format to retrieve.

  • html creates a full HTML markup including srcset;
  • url or src gets just the image url;
  • id gets the image ID. This is the same as just using get_term_meta()

Default is html

size

(string) Any built-in or user-defined media size. If missing or invalid, full is used.

Default is full

attr

(string|array) Attributes applied to the requested image html. This is passed through to wp_get_attachment_image() so see its API page for details.

Default is empty

fallback

(string) What to return if no term image is assigned.

  • placeholder will return the default image in the requested format except for ID, which will return null (because there is no ID for the default image);
  • Anything else will return null.

Default is placeholder

term

(WP_Term|int) Term object or term ID.

Default is the term taken from the main query.

Examples

This example shows the default usage, which will get the full HTML for the image assigned to the current term, or the HTML for the default image.

$url = gtaxi_get_taxonomy_image();

This is the same as the above, except for a specific term. Note that you can supply either a term object or term ID.

$url = gtaxi_get_taxonomy_image( array( 
    'term' => 123,
) );

This one will get only the URL, and return nothing if an image is not set.

$url = gtaxi_get_taxonomy_image( array( 
    'format'   => 'url', 
    'fallback' => '' 
) );

You can use this function with the many actions and filters that come with genesis to put the image out for a term wherever you like.

Request a Quote

Thanks for taking the time to learn about what we can do for you. When you’re ready, send us some brief information about you and your project. We’ll follow up with you and together we’ll develop a game plan.

Please do not put any passwords into this form. Once we’ve had a chance to speak we’ll arrange for a secure way to transmit all the info we’ll need.

Custom sites typically start at $4000.

Combined.3

Mike is a content strategist, designer and developer. With over 17 years of experience, he'll help plan and structure your web content, bringing it to life in a beautiful and effective design.

Quick Links

  • Web Design + Development
  • WordPress Site Management
  • My Plugins
hello@codenamemiked.com 613-866-7164

© 2003-2020 All Rights Reserved

© 2003- All Rights Reserved Site by <use xlink:href="/assets/cnmd-footer.svg#cnmd-logo-darker">