Search code examples
phpdrupaldrupal-7

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


I have attached icons to taxonomy terms and referenced the term in the node:

field_accreditation_icon is the field on the taxonomy term. field_accreditation is the field on the node.

Placing this in node.tpl.php displays the correct icon:

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

How would I render the icon as the ImageCache preset 'medium'?

Thank you!


Solution

  • You need to get the uri for that image then create image url with theme,

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

    image uri can be get by using taxonomy_term_load($tid);