Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I wanted to put my imagefield field above the title on my pages. I couldn't find any good documentation. Finally, I came up with:
<?php if ($node->field_your_name[0]): ?>
<?php print theme(
'imagefield_image',
$node->field_your_name[0],
$node->field_your_name[0]["alt"],
$node->field_your_name[0]["title"]);
?>
<?php endif; ?>
It seems to work. If you know a better way, please comment.
Imagecache + thickbox
<?php if ($node->field_your_name[0]): ?>
<?php print theme(
'imagefield_image_imagecache_thickbox',
'min', // name of preset
$field_your_name[0],
$field_your_name[0]['filepath'],
$field_your_name[0]['alt'],
$field_your_name[0]['title']
);
?>
<?php endif; ?>
Comments
Faster
It's also possible to do the following (Drupal 6):
Thank you for this snippet!
Thank you for this snippet! Worked like a charm. Only problem was the imagefield kept showing up twice, once above the title and the other within the content. With CSS I hid it. Is there another way to only have it display once?
Hide it in "display fields"
Hide it in "display fields" in the content type