You are here

function imagefield_tokens_filefield_paths_process_file in ImageField Tokens 6

Same name and namespace in other branches
  1. 5 imagefield_tokens.module \imagefield_tokens_filefield_paths_process_file()

Implementation of hook_filefield_paths_process_file().

File

./imagefield_tokens.module, line 52

Code

function imagefield_tokens_filefield_paths_process_file($new, &$file, $settings, $node, $update) {
  if (in_array($file['widget'], _imagefield_tokens_support_list())) {
    $file['field']['data']['alt'] = isset($file['field']['data']['alt']) ? $file['field']['data']['alt'] : '';
    $file['field']['data']['title'] = isset($file['field']['data']['title']) ? $file['field']['data']['title'] : '';
    $orig = array(
      'alt' => $file['field']['data']['alt'],
      'title' => $file['field']['data']['title'],
    );
    if (!empty($orig['alt'])) {
      $file['field']['data']['alt'] = filefield_paths_process_string($orig['alt'], 'node', $node);
      $file['field']['data']['alt'] = filefield_paths_process_string($file['field']['data']['alt'], 'field', array(
        0 => $file['field'],
      ));
    }
    if (!empty($orig['title'])) {
      $file['field']['data']['title'] = filefield_paths_process_string($orig['title'], 'node', $node);
      $file['field']['data']['title'] = filefield_paths_process_string($file['field']['data']['title'], 'field', array(
        0 => $file['field'],
      ));
    }
  }
}