Adding Islandora Viewers Capability to Basic Image Solution Pack
Putting this here because I didn't see it mentioned elsewhere and it might be useful for others. Thinking about the history of the Islandora solution packs for different media types, the Basic Image Solution Pack was probably the first one written. Displaying a JPEG image, after all, is -- well -- pretty basic. I'm working on an Islandora project where I wanted to add a viewer to Basic Image objects, but I found that the solution pack code didn't use them. Fortunately, Drupal has some nice ways for me to intercede to add that capability!
Step 1: Alter the /admin/islandora/solution_pack_config/basic_image form
The first step is to alter the solution pack admin form to add the Viewers panel. Drupal gives me a nice way to alter forms with hook_form_FORM_ID_alter().
1 2 3 4 5 6 7 8 9 |
|
Step 2: Insert ourselves into the theme preprocess flow
The second step is a little trickier, and I'm not entirely sure it is legal. We're going to set a basic image preprocess hook and in it override the contents of $variables['islandora_content']. We need to do this because that is where the viewer sets its output.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
I have a sneaking suspicion that the hooks are called in alphabetical order, and since islandora_ia_viewers comes after islandora_basic_image it all works out. (We need our function to be called after the Solution Pack's preprocess function so our 'islandora_content' value is the one that is ultimately passed to the theming function. Still, it works!