1

Is it possible to get the fid of an image from a taxonomy term?

1 Answer 1

6

Yes, it is.

$tid = 1; // Term id
$term = taxonomy_term_load($tid); // Load term
// Output term data with debug()
// See watchdog log at /admin/reports/dblog
debug($term, 'Taxonomy Term'); 

For example, file fid will be

$fid = $term->field_image[LANGUAGE_NONE][0]['fid'];

You could also get the rendered image, or url with something like:

// Get rendered HTML image tag using image styles.
$image = theme('image_style', 'medium', $term->field_image[LANGUAGE_NONE][0]['uri']);

// Get path to image style image
$path = image_style_url('medium', $term->field_image[LANGUAGE_NONE][0]['uri']);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.