Browse Source

Merge pull request #422 from willtp87/7.x.tn_scale

tn scale in utilities
pull/424/head
Morgan Dawe 11 years ago
parent
commit
274100e0a8
  1. 38
      includes/utilities.inc
  2. 2
      islandora.info

38
includes/utilities.inc

@ -943,3 +943,41 @@ function islandora_event_status() {
$text = ($results) ? t('The status messages above will be deleted after viewing this page.') : t('No messages to display.');
return array('#markup' => $text);
}
/**
* Scales the given image.
*
* @param object $file
* The image file to scale.
* @param int $width
* The width to scale the derived image to.
* @param int $height
* The height to scale the derived image to.
*
* @return bool
* TRUE if successful, FALSE otherwise.
*/
function islandora_scale_thumbnail($file, $width, $height) {
$real_path = drupal_realpath($file->uri);
$image = image_load($real_path);
try {
if (!empty($image)) {
$scale = image_scale($image, $width, $height, TRUE);
if ($scale) {
return image_save($image);
}
}
}
catch (exception $e) {
drupal_set_message(t(
"Islandora failed to scale image with message: '@message'",
array("@message" => $e->getMessage())));
watchdog(
'islandora',
'Islandora failed to scale image.<br/> With stack: @trace',
array('@trace' => $e->getTraceAsString()),
WATCHDOG_ERROR
);
}
return FALSE;
}

2
islandora.info

@ -1,6 +1,8 @@
name = Islandora
description = "View and manage Fedora objects"
package = Islandora
dependencies[] = image
dependencies[] = file
version = 7.x-dev
core = 7.x
configure = admin/islandora/configure

Loading…
Cancel
Save