*/ /** * Implementation of hook_help(). */ function video_ffmpeg_helper_help($section) { switch ($section) { case 'admin/modules#description': return t('Enable thumbnails support for video module.'); } } /** * Implementation of hook_menu() */ function video_ffmpeg_helper_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array( 'path' => 'admin/content/video/ffmpeg_helper', 'title' => t('Video ffmpeg Helper'), 'description' => t('Administer video_ffmpeg_helper module settings'), 'callback' => 'drupal_get_form', 'callback arguments' => array('video_ffmpeg_helper_admin_settings'), 'access' => user_access('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); } return $items; } /** * Validation for settings form */ function video_ffmpeg_helper_admin_settings_validate($form_id, &$form_values, &$form) { if ($form_values['video_ffmpeg_helper_auto_thumbnail']) { if (function_exists('is_executable')) { $test = 'is_executable'; } else { $test = 'file_exists'; } if (!$test($form_values['video_ffmpeg_helper_ffmpeg_path'])) { form_set_error('video_image_ffmpeg_path', t('Set correct path for thumbnailer')); } if (!is_numeric($form_values['video_ffmpeg_helper_auto_thumbnail_seek'])) { form_set_error('video_ffmpeg_helper_auto_thumbnail_seek', t('Seek time must be an integer')); } $options = $form_values['video_ffmpeg_helper_thumbnailer_options']; if (!strstr($options, '%videofile') || !strstr($options, '%thumbfile')) { form_set_error('video_ffmpeg_helper_thumbnailer_options', t('Thumbnail options must contain mandatory arguments %videofile and %thumbfile')); } } } /** * Settings form */ function video_ffmpeg_helper_admin_settings() { // let's execute after video_image if (module_exists('video_image')) { if (variable_get('video_ffmpeg_helper_auto_thumbnail', 0)) { $upload_weight = db_result(db_query("SELECT weight FROM {system} WHERE name='video_image'")); db_query("UPDATE {system} SET weight=".($upload_weight+1)." WHERE name='video_ffmpeg_helper'"); } } $form['video_ffmpeg_helper_ffmpeg_path'] = array( '#type' => 'textfield', '#title' => t('Ffmpeg executable path'), '#description' => t('Set the full path to the ffmpeg executable here.'), '#default_value' => variable_get('video_ffmpeg_helper_ffmpeg_path', '/usr/bin/ffmpeg'), ); $form['autothumb'] = array( '#type' => 'fieldset', '#title' => t('Automatic video thumbnailing'), '#collapsible' => TRUE, '#collapsed' => TRUE ); $form['autothumb']['video_ffmpeg_helper_auto_thumbnail'] = array( '#type' => 'checkbox', '#title' => t('Auto thumbnail for videos'), '#description' => t('If set up correctly, this will auto-generate a thumbnail for each video created.'), '#default_value' => variable_get('video_ffmpeg_helper_auto_thumbnail', false), ); $form['autothumb']['video_ffmpeg_helper_auto_thumbnail_only'] = array( '#type' => 'checkbox', '#title' => t('Use auto-thumbnailer exclusively for video images'), '#description' => t('If checked, this will disable the file upload box for the user-supplied thumbnail. Only check this if you have checked to be sure that auto-thumbnailing works. Auto thumbnail must be selected for this to be enabled.'), '#default_value' => variable_get('video_ffmpeg_helper_auto_thumbnail_only', false), '#disabled' => !variable_get('video_ffmpeg_helper_auto_thumbnail', false), ); $form['autothumb']['video_ffmpeg_helper_thumbnailer_options'] = array( '#type' => 'textfield', '#title' => t('Video thumbnailer options'), '#description' => t('Provide the options for the thumbnailer. Available argument values are: ').'
\n$tnail_output\n"); } if (!file_exists($thumbfile)) { drupal_set_message(t('video_image_auto_thumbnail: file %file does not exist', array('%file' => $thumbfile)), 'error'); } $file = array( 'filename' => $_SESSION['video_upload_file']->filename . ".video-thumb.jpg", 'filemime' => 'image/jpeg', 'filesize' => filesize($thumbfile), 'filepath' => $thumbfile, 'nid' => $node->nid, ); $_SESSION['video_upload_file']->thumbnailed = TRUE; if ($debug) { if ($tnail_return) { drupal_set_message(t('Failed to thumbnail video')); } else { drupal_set_message(t('Successfully thumbnailed video')); } } return (object)$file; }