返回Drupal 7节点模板中缓存的图像字段


Returning an image cached image field in a Drupal 7 node template

我将图标附加到分类法术语上,并在节点中引用该术语:

field_accreditation_icon是分类学项上的字段。field_accreditation为节点上的字段。

将其放在node.tpl.php中显示正确的图标:

  <?php
    $term = taxonomy_term_load($node->field_accreditation['und'][0]['tid']);
    $result = field_view_field('taxonomy_term',$term,'field_accreditation_icon');
    echo render($result);
  ?>

我如何渲染图标作为ImageCache预设'介质'?

谢谢!

您需要获取该图像的uri,然后创建带有主题的图像url,

<?php
// $img_uri will be the image uri value getting from database
print '<img src="'.image_style_url("medium", $img_uri).'" />';
?>

image uri可以通过使用taxonomy_term_load($tid);

得到