function image_field_caption_tokens in Image Field Caption 7
Implements hook_tokens().
File
- ./
image_field_caption.module, line 347 - Provides a caption textarea for image fields.
Code
function image_field_caption_tokens($type, $tokens, array $data = array(), array $options = array()) {
// Replace the caption token with the caption data attached to the file, if
// it exists.
$replacements = array();
if (isset($data) && isset($data['file'])) {
foreach ($tokens as $name => $original) {
if ($name == 'caption' && isset($data['file']->caption)) {
$replacements[$original] = $data['file']->caption;
break;
}
}
}
return $replacements;
}