Hook for Field Duplication I have a custom module that is formatting the display of an image field, which can accept multiple values.
I would like to know what hook I should use to duplicate the first value of the field (e.g. "[image1]"), and add it back to the beginning of the array (with array_unshift() I guess) before the rest of my functions format the display/theme of the field.

So what was


[image1]
[image2]
[image3]


becomes


[image1]
[image1]
[image2]
[image3]


I am then going to theme them separately, but I think I already have that part figured out.

I am currently using hook_field_formatter_view(), and have tried to just add it to the beginning of the $items array at the top of the function, but that didn't seem to work. If I immediately dprint_r() the $items array after this it shows, but only 3 items get output; I am assuming that the number of field gets determined elsewhere.
You want hook_field_formatter_prepare_view() instead. Note this hook operate on a group of entities, not on a single one.

Here's a working snippet. Some array-fu is needed to not end up writing an ugly loop of ten lines, since deltas must be preserved linear.

&lt;?php

function MODULE_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &amp;$items, $displays) {
  foreach ($entities as $id =&gt; $entity) {
    $array = array(0 =&gt; $items[$id][0], 1 =&gt; $items[$id][0]);
    if (count($items[$id]) &gt; 1) {
      array_splice($array, 2, 0, array_slice($items[$id], 1));
    }
    $items[$id] = $array;
  }
}