You are here

function mediafield_field_insert in D7 Media 7.4

Same name and namespace in other branches
  1. 7.2 modules/mediafield/mediafield.module \mediafield_field_insert()
  2. 7.3 modules/mediafield/mediafield.module \mediafield_field_insert()

Implements hook_field_insert().

File

modules/mediafield/mediafield.module, line 233
Provide a "Multimedia asset" field.

Code

function mediafield_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);

  // Add a new usage of each uploaded file.
  foreach ($items as $item) {
    $file = (object) $item;
    file_usage_add($file, 'mediafield', $entity_type, $id);
  }
}