You are here

function emthumb_emfield_widget_extra in Embedded Media Field 6

Same name and namespace in other branches
  1. 5 contrib/emthumb/emthumb.module \emthumb_emfield_widget_extra()
  2. 6.3 contrib/emthumb/emthumb.module \emthumb_emfield_widget_extra()
  3. 6.2 contrib/emthumb/emthumb.module \emthumb_emfield_widget_extra()

Implements hook_emfield_widget_extra().

This is called by _emfield_emfield_widget (in emfield.cck.inc) when building the widget on the node form. It creates a file upload element so the editor may upload a new thumbnail to replace the provider default.

File

contrib/emthumb/emthumb.module, line 317
Allows for custom thumbnail overrides to Embedded Media Field.

Code

function emthumb_emfield_widget_extra($form, $form_state, $field, $items, $delta = 0, $module) {
  $element = array();

  // Construct the thumbnail fieldset with the custom label.
  // We do not want this fieldset if there are no items
  // and the editor can't upload a thumb
  if (!empty($items) && !empty($items[0]['value']) && $field['widget']['emthumb_store_local_thumbnail'] || $field['widget']['emthumb']) {
    $emthumb_label = isset($field['widget']['emthumb_label']) ? $field['widget']['emthumb_label'] : (isset($field['widget']['label']) ? t('@field custom thumbnail', array(
      '@field' => $field['widget']['label'],
    )) : t('Custom thumbnail'));
    $element['emthumb'] = array(
      '#type' => 'fieldset',
      '#title' => $emthumb_label,
      '#collapsible' => TRUE,
      '#collapsed' => $field['widget']['emthumb_start_collapsed'],
      '#tree' => TRUE,
    );
    if (isset($field['widget']['emthumb_weight'])) {
      $element['emthumb']['#weight'] = $field['widget']['emthumb_weight'];
    }
    $element['emthumb']['emthumb'] = array(
      '#type' => 'emthumb_widget',
      '#title' => $field['widget']['emthumb'] ? t('New upload') : '',
      '#field' => $field,
      '#fieldname' => $field['field_name'],
      '#items' => $items,
      '#delta' => $delta,
    );
  }
  return $element;
}