Skip to content

Commit

Permalink
Not showing broken img when lacking access to PREVIEW
Browse files Browse the repository at this point in the history
  • Loading branch information
willtp87 committed Nov 23, 2015
1 parent 4c7e7bb commit fc5991f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions theme/islandora-pdf.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<div class="islandora-pdf-content">
<?php print $islandora_content; ?>
</div>
<?php if (isset($islandora_download_link)): ?>
<?php print $islandora_download_link; ?>
<?php endif; ?>
<?php endif; ?>
<?php if (isset($islandora_download_link)): ?>
<?php print $islandora_download_link; ?>
<?php endif; ?>
</div>
<div class="islandora-pdf-metadata">
Expand Down
13 changes: 6 additions & 7 deletions theme/theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,20 @@ function islandora_pdf_preprocess_islandora_pdf(&$variables) {
$variables['islandora_thumbnail_img'] = theme('image', $params);
}
// Preview image + link.
if (isset($islandora_object['PREVIEW'])) {
if (isset($islandora_object['PREVIEW']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $islandora_object['PREVIEW'])) {
$preview_url = url("islandora/object/{$islandora_object->id}/datastream/PREVIEW/view");
$params = array(
'title' => $islandora_object->label,
'path' => $preview_url,
);
$variables['islandora_preview_img'] = theme('image', $params);
$variables['islandora_content'] = l($variables['islandora_preview_img'], $variables['islandora_full_url'], array('html' => TRUE));
// Sanitize this object name a bit.
$sanitized_label = preg_replace('/[^A-Za-z0-9_\-]|\.pdf$/', '_', $islandora_object->label);
$download_url = 'islandora/object/' . $islandora_object->id . '/datastream/OBJ/download/' . $sanitized_label . '.pdf';
$download_text = t("Download pdf");
$variables['islandora_download_link'] = l($download_text, $download_url, array('attributes' => array('class' => array('islandora-pdf-link'))));
}

// Sanitize this object name a bit and provide download link.
$sanitized_label = preg_replace('/[^A-Za-z0-9_\-]|\.pdf$/', '_', $islandora_object->label);
$download_url = 'islandora/object/' . $islandora_object->id . '/datastream/OBJ/download/' . $sanitized_label . '.pdf';
$download_text = t("Download pdf");
$variables['islandora_download_link'] = l($download_text, $download_url, array('attributes' => array('class' => array('islandora-pdf-link'))));
}
}

Expand Down

0 comments on commit fc5991f

Please sign in to comment.