Drupal: How do I manually print Taxonomy Images
Here is the code I use开发者_运维问答d to print taxonomy images per specific vocabulary using Taxonomy Image:
<?php
$vid = 19;
$terms = taxonomy_node_get_terms_by_vocabulary($node,$vid);
$new_terms = array();
if ($terms) {
foreach ($terms as $term) {
$term = taxonomy_image_display($term->tid) as $image);
print '<div class="color">' . $image . '</div>';
$new_terms[] = $image;
}
}
?>
Your code is broken. Did you mean:
<?php
$vid = 19;
$terms = taxonomy_node_get_terms_by_vocabulary($node,$vid);
$new_terms = array();
if ($terms) {
foreach ($terms as $term) {
$image = taxonomy_image_display($term->tid);
print '<div class="color">' . $image . '</div>';
$new_terms[] = $image;
}
}
?>
This is correct PHP and should work.
精彩评论