1

I have a multi-valued image field and I'd like to use its delta value with the Custom Formatters module. What I want to do would be really simple with html+tokens if it were to work:

<div id="cf">
  <a href="[node:url]"><img class="bottom"  style="border:0;"src="[node:field_image:0]" alt="[node:title]" ></a>
  <a href="[node:url]"><img class="top"  style="border:0;" src="[node:field_image:1]" alt="[node:title]" ></a>
</div>

However, I don't see the option for the delta value available in the list of tokens available, and using that code would just end up with [node:field_image:0] and [node:field_image:1] being replaced as src=""

Could you please advice me on how to do this? I think I need to use php but I don't know how. Thank you very much!

-1

here a sample for rendering (image) fields but you can easily access to other fields of entity:

$output = '';
foreach ($variables['#items'] as $item) {
  $output .= theme('file_link', array('file' => (object) $item));
}
return $output;

Another line example for manual image rendering:

$output .= '<img typeof="foaf:Image" src="'.image_style_url('YOUR_IMAGE_STYLE', $your_entity->your_field['und'][0]['uri']).'" alt="'.$your_entity->your_field['und'][0]['alt'].'"/>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.