You are here

function pdf_field_formatter_view in PDF 7

Implements hook_field_formatter_view().

File

includes/pdf.field.inc, line 123

Code

function pdf_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  $settings = $display['settings'];
  switch ($display['type']) {
    case 'pdf_default':
      foreach ($items as $delta => $item) {
        if (isset($item['filemime']) && strpos($item['filemime'], 'pdf') || isset($item['url']) && substr($item['url'], -3) == 'pdf') {
          $element[$delta] = array(
            '#theme' => 'pdf_formatter_default',
            '#file' => (object) $item,
            '#keep_pdfjs' => $settings['keep_pdfjs'],
            '#width' => $settings['width'],
            '#height' => $settings['height'],
          );
        }
      }
      break;
    case 'pdf_thumbnail':
      foreach ($items as $delta => $item) {
        if (isset($item['filemime']) && strpos($item['filemime'], 'pdf') || isset($item['url']) && substr($item['url'], -3) == 'pdf') {
          $element[$delta] = array(
            '#theme' => 'pdf_formatter_thumbnail',
            '#file' => (object) $item,
            '#scale' => $settings['scale'],
            '#width' => $settings['width'],
            '#height' => $settings['height'],
          );
        }
      }
      break;
    case 'pdf_pages':
      foreach ($items as $delta => $item) {
        if (isset($item['filemime']) && strpos($item['filemime'], 'pdf') || isset($item['url']) && substr($item['url'], -3) == 'pdf') {
          $element[$delta] = array(
            '#theme' => 'pdf_formatter_pages',
            '#file' => (object) $item,
            '#scale' => $settings['scale'],
          );
        }
      }
      break;
  }
  return $element;
}