Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Taxonomy Image APIs
taxonomy_image_display($tid, $tags = null, $profile = null, $overrides = array())
Display the image associated with the given term id.
- Parameters:
- $tid
- The taxonomy term identifier.
- $tags
- Optional. Additional attributes, in standard Drupal attributes array format ('attribute_name' => 'attribute_value').
- $profile
- Optional. An Imagecache preset name.
- $overrides
- Optional. An array of overrides to the configured settings that will be applied for this one call. Use this with great care.
- wrapper -> Adds a wrapper division to the generated URL.
- imagecache_preset -> Specifies the Imagecache preset to use. Note: the "profile" parameter is better for this.
- recursive -> Use recursive image search to find the image to use.
- resize -> Which type of Taxonomy Image resizing to use.
- width -> The width to use for Taxonomy Image resizing.
- height -> The height to use for Taxonomy Image resizing.
- Returns:
- An HTML string containing a themed ('image' or 'imagecache') "<img>" element.
- Note:
- If you want to call both "taxonomy_image_display" and "taxonomy_image_get_object," call for the object first. The object is statically cached so it will already be available when you get the image.
taxonomy_image_get_url($tid)
Get a URL for an image, for use in CSS, HTML, or other client-side code.
- Parameters:
- $tid
- The taxonomy term identifier.
- Returns:
- A URL for the image.
taxonomy_image_get_object($tid, $recursive = null)
Get an image object with more useful data for custom formatting.
- Parameters:
- $tid
- The taxonomy term identifier.
- $recursive
- Override the configured setting for recursive display. The default is to use the configuration.
- Returns:
- An object containing:
- path -> The file path for the image.
- name -> The term name.
- description -> The description of the term, as entered by the admin.
- url -> The URL for the image.
- width -> The width for the image.
- height -> The height for the image.
- type -> The image type value (see http://us2.php.net/manual/en/function.getimagesize.php).
- tags -> The width and height formatted for inclusion within HTML.
- bits -> As returned from "getimagesize."
- channels -> As returned from "getimagesize."
- mime -> As returned from "getimagesize."
- term -> A formatted URL (or URL alias if available) for use as a "taxonomy/term/xxx" link.
- image -> An "<img>" element containing the width and height (but without using any resizing options).