What sounds like simple task in the first place, has taken me hours without getting a solution: All I want is to render single values of an imagefield just as in the normal node, i.e. as defined in content-field.tpl.php. This is important for me, because there I add captions from the Imagefield Extended module

I tried with content_format(), but with the "default" formatter it gives me just an icon and a link and with the "image_imagelink" formatter from the imagefield.module I get an image, but not as defined in content-field.tpl.php and in the node type's display settings:

print content_format('field_image', $vars['node']->field_image[1], 'default', $vars['node']);
print content_format('field_image', $vars['node']->field_image[1], 'image_imagelink', $vars['node'])

I have tried a couple of other things and searched for hours, but I cannot find an answer. Any ideas how I can render the image "just the normal way"?

The HTML out I want is a defined in the template something like this:

<div class="field field-type-filefield field-field-image">
  <div class="field-items">
    <div class="field-item odd">
      <a class="imagefield imagefield-lightbox2 imagefield-lightbox2-page-grid-6 imagefield-field_image imagecache imagecache-field_image imagecache-page-grid-6 imagecache-field_image-page-grid-6 lightbox-processed" rel="lightbox[field_image][Caption text]" href="http://example.com/files/imagecache/image_full/img/2014/img.jpg">
        <img width="364" height="242" title="Caption text" alt="Caption text" src="http://example.com/files/imagecache/page-grid-6/img/2014/img.jpg">
      <div class="img-meta">
        <div class="img-title">
          <p>Caption Text</p>
        <div class="img-source-info">
          <div class="img-source">
            <span class="img-source-label label">Source:</span> 
            <span class="img-source-content content">Source text</span>
          <div class="img-license">
            <span class="img-license-label label">Licence:</span> 
            <span class="img-license-content content">Licence text</span>

1 Answer 1


Do you have more than one image?

print content_format('field_image', $vars['node']->field_image[0], 'default', $vars['node']);
print content_format('field_image', $vars['node']->field_image[0], 'image_imagelink', $vars['node']);

Try again with [0] instead of [1]. I use those all the time and it works fine like that.

  • Hi Alexis, actually I was using a loop to print all the images, the "1" was just one instance, so that doesn't solve the problem. As I said, I changed some stuff in the field's template file and those changes are not reflected when I use content_format().
    – yotka
    Jul 13, 2014 at 13:27
  • Ah! I have to say I try to avoid using theme() in general because of all the caching and stuff, it often does not come out exactly as you want it. But anyway, in your case, you may have a cache problem. The theme() functions save all sorts of things in the cache under the hood and if those caches exist, they ignore your other changes. Jul 13, 2014 at 21:40

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.