Skip to content

Instantly share code, notes, and snippets.

@mjordan
Created January 12, 2014 23:22
Show Gist options
  • Save mjordan/8392069 to your computer and use it in GitHub Desktop.
Save mjordan/8392069 to your computer and use it in GitHub Desktop.
Example of pre hook_islandora_derivative derivative generation in Islandora
<?php
/**
* Implements hook_CMODEL_PID_islandora_object_ingested().
*/
function islandora_pdf_islandora_sp_pdf_islandora_object_ingested($object) {
module_load_include('inc', 'islandora_pdf', 'includes/derivatives');
islandora_pdf_create_all_derivatives($object);
}
function islandora_pdf_create_all_derivatives(AbstractObject $object) {
if (!isset($object['OBJ'])) {
drupal_set_message(t('Could not create image derivatives for %s. No image file was uploaded.',
array('%s' => $object->id)), 'error');
return FALSE;
}
$success = TRUE;
$file_uri = islandora_pdf_get_derivative_source_as_unmanaged_file($object);
$success &= islandora_pdf_add_tn_derivative($object, $file_uri);
$success &= islandora_pdf_add_preview_derivative($object, $file_uri);
if (!isset($object['FULL_TEXT']) && variable_get('islandora_pdf_create_fulltext', FALSE)) {
$success &= islandora_pdf_add_fulltext_derivative($object, $file_uri);
}
file_unmanaged_delete($file_uri);
return $success;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment