You are here

function media_field_insert in D7 Media 7

Implements hook_field_insert().

File

includes/media.fields.inc, line 393
: Provides a "Multimedia asset" field to the fields API

Code

function media_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, 'media', $entity_type, $id);
  }
}