diff options
Diffstat (limited to 'video.field.inc')
-rw-r--r-- | video.field.inc | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/video.field.inc b/video.field.inc index 0534efc..d81294c 100644 --- a/video.field.inc +++ b/video.field.inc @@ -137,11 +137,32 @@ function video_field_presave($entity_type, $entity, $field, $instance, $langcode function video_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { file_field_insert($entity_type, $entity, $field, $instance, $langcode, $items); // Create entry for video conversion if auto converison is enabled -// if ($field['settings']['autoconversion'] == 1) { -// foreach ($items as $delta => $item) { -// video_convert_process($item); -// } -// } + if ($field['settings']['autoconversion'] == 1) { + $nid = $entity->vid; + module_load_include('inc', 'video', '/includes/conversion'); + $video_conversion = new video_conversion; + foreach ($items as $delta => $item) { + // skip adding entry if bypass conversion is checked + if ($item['bypass_autoconversion'] == 1 || variable_get('video_bypass_conversion', FALSE)) { + // delete the conversion job if any + $video_conversion->delete_job($item); + return; + } + // Lets verify that we haven't added this video already. Multiple validation fails will cause this to be ran more than once + if (!$video = $video_conversion->load_job($item['fid'])) { + if (!($video_conversion->create_job($item, $nid))) + drupal_set_message(t('Something went wrong with your video job creation. Please check your recent log entries for further debugging.'), 'error'); + } + // if convert on save is checked + if ($item['convert_video_on_save'] == 1 || variable_get('video_convert_on_save', FALSE)) { + if (!$video_conversion->process($item['fid'])) { + drupal_set_message(t('Something went wrong with your video conversion. Please check your recent log entries for further debugging.'), 'error'); + } else { + drupal_set_message(t('Successfully converted your video.')); + } + } + } + } } /** |