You are here

function pdf_to_image_token_info in PDF to ImageField 7.3

Publish the filename of the source document as a token.

To enhance filefield_paths, this could be used to create the filepath of the derived document.

Implements hook_token_info().

File

./pdf_to_image.module, line 836
Generates thumbnail image(s) from an uploaded PDF.

Code

function pdf_to_image_token_info() {
  $info['tokens']['node']['pdf-source-filename'] = array(
    'name' => t("File name"),
    'description' => t("File name of the source PDF without extension."),
  );

  /*
    // Provide tokens for any fields that are used as pdf sources.
    // Do a complex lookup here to avoid having to do it in the token call itself.
    $all_fields = field_info_instances();
    // All entities, all bundles.
    foreach ($all_fields as $entity_type => $entity_fields) {
    foreach ($entity_fields as $bundle_id => $bundle_fields) {
    foreach (pdf_to_image_source_fields($entity_type, $bundle_id)
    as $field_id => $field_instance) {
    // THIS is a field I need to provide a token from
    // TODO - I really should index by field ID so the token generator
    // knows what to look for without analyzing the content type each time.
    // $info['tokens'][$entity_type][$field_id . ':pdf-filename'] = array(
    // But how...
    $info['tokens'][$entity_type]['pdf-source-filename'] = array(
    'name' => $field['label'],
    'description' => t("File name of the source PDF without extension."),
    );
    }

    }
    }
    // Fail. If I encode the field name into the token, then I can't scan for it
    // later until I know what the field name is. So no win there.
  */
  return $info;
}