You are here

function _fillpdf_process_image_tokens in FillPDF 7

Process image tokens.

Parameters

$entity_type:

$entity:

$obj:

$fields:

$image_data: TRUE if no images were replaced (and normal token processing should continue), and FALSE otherwise.

$transform_string:

1 call to _fillpdf_process_image_tokens()
fillpdf_merge_pdf in ./fillpdf.module
Constructs a page and sends it to the browser or saves it.

File

./fillpdf.module, line 962

Code

function _fillpdf_process_image_tokens($entity_type, $entity, $obj, &$fields, &$image_data, &$transform_string) {
  $entity_fields = field_read_fields(array(
    'entity_type' => $entity_type,
  ));
  foreach ($entity_fields as $field_name => $field_data) {
    if (!$field_data['type'] === 'image') {
      continue;
    }
    $info = entity_get_info($entity_type);
    $token_type = !empty($info['token type']) ? $info['token type'] : $entity;
    if ($obj->value === "[{$token_type}:{$field_name}]") {

      // It's a match!
      $image_field = field_get_items($entity_type, $entity, $field_name);
      if (!$image_field) {

        // We matched the token, but there was no file set.
        $transform_string = TRUE;
      }
      else {
        $image_path = $image_field[0]['uri'];
        _fillpdf_prepare_image_data($image_path, $obj, $fields, $image_data, $transform_string);
        return;
      }
    }
  }
  $transform_string = TRUE;
}