You are here

function video_field_insert in Video 7.2

Same name and namespace in other branches
  1. 7 video.field.inc \video_field_insert()

Implements hook_field_insert().

File

./video.field.inc, line 445
Implement a video field, based on the file module's file field.

Code

function video_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
  file_field_insert($entity_type, $entity, $field, $instance, $langcode, $items);

  // calling function to handle conversion when auto conversion is enabled
  _video_field_file_autoconversion($entity_type, $entity, $field, $instance, $langcode, $items);

  // Update the thumbnails to be permanent and register with entity
  $thumbnails = _video_field_get_all_thumbnails($field, $items);
  if (!empty($thumbnails)) {
    db_update('file_managed')
      ->fields(array(
      'status' => FILE_STATUS_PERMANENT,
    ))
      ->condition('fid', array_keys($thumbnails), 'IN')
      ->execute();
    file_field_insert($entity_type, $entity, $field, $instance, $langcode, $thumbnails);
  }

  // Update the thumbnails to be permanent and register with entity
  $converted = _video_field_get_all_converted($items);
  if (!empty($converted)) {
    file_field_insert($entity_type, $entity, $field, $instance, $langcode, $converted);
  }
}