I have a content type that has a custom template. My content type is article and I have a node--article.tpl.php that displays the following.

    print render($content['field_image']);
    print render($content['body']); 

I have a module that adds a featured image to each node if it is made a featured node in its options. I believe this is the code in the module that is causing it but I'm not positive.

function featured_nodes_field_extra_fields() {
  $extra = array();
  // Get feature types from the database.
  $featured_node_types = db_select('featured_nodes_types', 't')

  foreach($featured_node_types as $type => $feature) {
    foreach (node_type_get_names() as $name => $value) {
      $extra['node'][$name] = array(
        'display' => array(
          'featured_nodes_' . $type => array(
            'label' => $feature->label . ' - featured image',
            'description' => t('If this node is featured, display the associated image.'),
            'weight' => -10,
  return $extra;

function featured_nodes_node_view($node, $view_mode, $langcode) {
  if (!empty($node->featured_node)) {
    foreach ($node->featured_node as $delta => $values) {
      $node->content['featured_nodes_' . $values['feature_type']] = array(
        '#theme' => 'featured_node_image',
        '#node' => $node,
        '#view_mode' => $view_mode,
        '#db_values' => $values,

Despite my attempts I have not been able to print the featured image from node--article.tpl.php but I believe I got close. When I added

print render($featured_node[0]['image']);

It displayed 10080. And a unique number on each featured node. Possibly the field's id. But I was still unable to produce the image. Any ideas?

1 Answer 1


I managed to figure it out. I found a location in the module with this code.

function theme_featured_node_image($variables) {
  $fid = $variables['element']['#db_values']['image'];
  $file = file_load($fid);
  $url = file_create_url($file->uri);
  return theme('image', array('attributes' => array(), 'path' => $url));

Then I wrote

$file = file_load($featured_node[0]['image']);
$url = file_create_url($file->uri);
print '<img src="'.$url.'">';

Which allowed me to print the image.

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.