diff --git a/imagefield_tokens.module b/imagefield_tokens.module
index 3c8ba35..a872928 100644
--- a/imagefield_tokens.module
+++ b/imagefield_tokens.module
@@ -45,7 +45,7 @@ function imagefield_tokens_form_field_ui_field_edit_form_alter(&$form, &$form_st
$form_settings['alt_settings']['alt_field_sync_title'] = array(
'#type' => 'checkbox',
'#title' => t('Synchronize with Title field'),
- '#description' => t('Replaces Alt field value with the Title field value (below) during node_save().'),
+ '#description' => t('Replaces Alt field value with the Title field value (below) during entity saving.'),
'#default_value' => $settings['alt_field_sync_title'],
'#states' => array(
'disabled' => array(
@@ -68,15 +68,35 @@ function imagefield_tokens_form_field_ui_field_edit_form_alter(&$form, &$form_st
$form_settings['alt_settings']['alt_field_default'] = array(
'#type' => 'textfield',
'#title' => t('Default value'),
- '#description' => t('Default field value. Used after image upload, and during node_save() when Alt field is empty. Tokens are replaced only during node_save().'),
+ '#description' => t('Default field value. Used after image upload, and just before field data get saved when Alt field is empty. Tokens are replaced only during entity saving.'),
'#default_value' => $settings['alt_field_default'],
'#size' => 60,
'#maxlength' => 128,
);
if (module_exists('token')) {
+ $token_types = array();
+ if (module_exists('entity')) {
+ module_load_include('inc', 'entity', 'entity_token.tokens');
+ // get a full list of token types
+ $token_types_chained = entity_token_types_chained();
+ // get the token type of given entity type
+ $token_types[] = array_search($form['#instance']['entity_type'], $token_types_chained);
+ }
+ else {
+ switch ($form['#instance']['entity_type']) {
+ // usually entities have the same token type name as the entity type name
+ default:
+ $token_types[] = $form['#instance']['entity_type'];
+ break;
+ // except for taxonomy_term
+ case 'taxonomy_term':
+ $token_types[] = 'term';
+ break;
+ }
+ }
$form_settings['alt_settings']['token_help'] = array(
'#theme' => 'token_tree',
- '#token_types' => array('node'),
+ '#token_types' => $token_types,
);
}
@@ -109,7 +129,7 @@ function imagefield_tokens_form_field_ui_field_edit_form_alter(&$form, &$form_st
$form_settings['title_settings']['title_field_default'] = array(
'#type' => 'textfield',
'#title' => t('Default value'),
- '#description' => t('Default field value. Used after image upload, and during node_save() when Title field is empty. Tokens are replaced only during node_save().'),
+ '#description' => t('Default field value. Used after image upload, and just before field data get saved when Title field is empty. Tokens are replaced only during entity saving..'),
'#default_value' => $settings['title_field_default'],
'#size' => 60,
'#maxlength' => 128,
@@ -117,7 +137,7 @@ function imagefield_tokens_form_field_ui_field_edit_form_alter(&$form, &$form_st
if (module_exists('token')) {
$form_settings['title_settings']['token_help'] = array(
'#theme' => 'token_tree',
- '#token_types' => array('node'),
+ '#token_types' => $token_types,
);
}
}
@@ -222,4 +242,3 @@ function imagefield_tokens_field_attach_presave($entity_type, $entity) {
}
}
}
-