You are here

function atom_reference_field_diff_view_prepare in Scald: Media Management made easy 7

Diff field callback for preloading the scald atom entities.

File

modules/fields/atom_reference/atom_reference.module, line 461
Defines a new field type, allowing to directly reference Scald Atoms from a node.

Code

function atom_reference_field_diff_view_prepare(&$old_items, &$new_items, $context) {
  $sids = array();
  foreach (array_merge_recursive($old_items, $new_items) as $info) {
    $sids[$info['sid']] = $info['sid'];
  }
  $atoms = scald_atom_load_multiple($sids);
  foreach ($old_items as $delta => $info) {
    $old_items[$delta]['atom'] = isset($atoms[$info['sid']]) ? $atoms[$info['sid']] : NULL;
  }
  foreach ($new_items as $delta => $info) {
    $new_items[$delta]['atom'] = isset($atoms[$info['sid']]) ? $atoms[$info['sid']] : NULL;
  }
}