You are here

function template_preprocess_imagefield_extended_image in ImageField Extended 6.3

Same name and namespace in other branches
  1. 6.4 imagefield_extended.module \template_preprocess_imagefield_extended_image()

Process variables for imagefield-extended-image.tpl.php.

See also

imagefield-extended-image.tpl.php

File

./imagefield_extended.module, line 409
Insert additional fields into an ImageField data array.

Code

function template_preprocess_imagefield_extended_image(&$variables) {
  $item = $variables['item'];
  $fapi_fields = $variables['fapi_fields'];
  $field_name = empty($item['field_name']) ? 'extended' : $item['field_name'];
  $variables += array(
    'values' => array(),
    'fields' => array(),
    'image' => '',
    'field_name' => check_plain($field_name),
    'image_class' => 'imagefield imagefield-' . $field_name,
  );
  $item = (array) $item;
  if (!is_file($item['filepath'])) {
    $variables['image'] = '<!-- File not found: ' . check_plain($item['filepath']) . ' -->';
  }
  else {
    if ($item['formatter'] == 'ife') {
      $variables['image'] = theme('imagefield_image', $item, $item['data']['alt'], $item['data']['title'], array(
        'class' => $variables['image_class'],
      ));
    }
    else {
      $presetname = drupal_substr($item['formatter'], 0, strrpos($item['formatter'], '_'));
      $variables['image_class'] .= " imagecache-{$presetname} imagecache-{$item['formatter']}";
      $variables['image'] = theme('imagecache', $presetname, $item['filepath'], $item['data']['alt'], $item['data']['title'], array(
        'class' => $variables['image_class'],
      ));
    }
  }

  // Checkboxes are value FAPI 'item' fields, textfields are 'value' fields.
  foreach (element_children($fapi_fields) as $key) {
    $variables['values'][$key] = $fapi_fields[$key]['#value'];
    $variables['fields'][$key] = drupal_render($fapi_fields[$key]);
  }
  $variables['fields'] = array_filter($variables['fields']);
}