View source
<?php
function imagefield_tokens_form_alter($form_id, &$form) {
if (isset($form['module']) && $form['module']['#value'] == 'imagefield') {
$ifp = array(
'alt' => array(
'title' => 'ALT text',
'form_path' => &$form['widget']['alt_settings'],
),
'title' => array(
'title' => 'Title text',
'form_path' => &$form['widget']['title_settings'],
),
);
foreach ($ifp as $name => &$field) {
unset($field['form_path'][$name]['#suffix']);
$field['form_path'][$name . '_tokens'] = array(
'#type' => 'fieldset',
'#title' => t('!title replacement patterns', array(
'!title' => $field['title'],
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => theme_filefield_paths_token_help(),
);
}
}
}
function imagefield_tokens_filefield_paths_process_file($new, &$file, $settings, $node, $update) {
if ($file['widget'] == 'image') {
$orig = array(
'alt' => $file['field']['alt'],
'title' => $file['field']['title'],
);
$file['field']['alt'] = filefield_paths_process_string($file['field']['alt'], 'node', $node);
$file['field']['alt'] = filefield_paths_process_string($file['field']['alt'], 'field', array(
0 => $file['field'],
));
$file['field']['title'] = filefield_paths_process_string($file['field']['title'], 'node', $node);
$file['field']['title'] = filefield_paths_process_string($file['field']['title'], 'field', array(
0 => $file['field'],
));
}
}