function emthumb_emfield_widget_extra in Embedded Media Field 6.2
Same name and namespace in other branches
- 5 contrib/emthumb/emthumb.module \emthumb_emfield_widget_extra()
- 6.3 contrib/emthumb/emthumb.module \emthumb_emfield_widget_extra()
- 6 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 373 - Allows for custom thumbnail overrides to Embedded Media Field.
Code
function emthumb_emfield_widget_extra($form, $form_state, $field, $items, $delta = 0, $module) {
if (module_exists('devel_themer') && (user_access('access devel theme information') || user_access('access devel information'))) {
drupal_set_message(t('Files may not be uploaded while the Theme Developer tool is enabled. It is highly recommended to <a href="!url">disable this module</a> unless it is actively being used.', array(
'!url' => url('admin/build/modules'),
)), 'error');
}
$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']) {
$field_name = $field['field_name'];
$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,
// Wrapper for fieldset contents (used by ahah.js).
'#prefix' => '<div id="emthumb-wrapper-' . $field_name . '-' . $delta . '">',
'#suffix' => '</div>',
);
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,
'#field_name' => $field['field_name'],
'#type_name' => $field['type_name'],
'#items' => $items,
'#delta' => $delta,
);
}
return $element;
}