Created
January 12, 2014 23:22
-
-
Save mjordan/8392069 to your computer and use it in GitHub Desktop.
Example of pre hook_islandora_derivative derivative generation in Islandora
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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