Index: imagecache_actions.inc
===================================================================
--- imagecache_actions.inc (revision 129)
+++ imagecache_actions.inc (working copy)
@@ -152,6 +152,8 @@
'height' => '',
'xoffset' => '',
'yoffset' => '',
+ 'width_upcrop' => 1,
+ 'height_upcrop' => 1
);
$form['width'] = array(
'#type' => 'textfield',
@@ -177,20 +179,53 @@
'#default_value' => $data['yoffset'],
'#description' => t('Enter an offset in pixels or use a keyword: top, center, or bottom.'),
);
+ $form['width_upcrop'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => (isset($data['width_upcrop'])) ? $data['width_upcrop'] : 0,
+ '#title' => t('Allow width upcropping'),
+ '#description' => t('Let crop make images wider than their original size'),
+ );
+ $form['height_upcrop'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => (isset($data['height_upcrop'])) ? $data['height_upcrop'] : 0,
+ '#title' => t('Allow height upcropping'),
+ '#description' => t('Let crop make images taller than their original size'),
+ );
return $form;
}
function theme_imagecache_crop($element) {
$data = $element['#value'];
- return t('width: @width, height: @height, xoffset: @xoffset, yoffset: @yoffset', array(
+ if ($data['width_upcrop']) {
+ $upcrop[] = 'width';
+ }
+ if ($data['height_upcrop']) {
+ $upcrop[] = 'height';
+ }
+ if (!empty($upcrop)) {
+ $upcrop = t(implode(' and ', $upcrop) . ' upcropping');
+ }
+ else {
+ $upcrop = t('no upcrop');
+ }
+
+ return t('width: @width, height: @height, xoffset: @xoffset, yoffset: @yoffset (@upcrop)', array(
'@width' => $data['width'],
'@height' => $data['height'],
'@xoffset' => $data['xoffset'],
'@yoffset' => $data['yoffset'],
+ '@upcrop' => $upcrop,
));
}
function imagecache_crop_image(&$image, $data) {
+ if (!$data['height_upcrop'] && $image->info['height'] < $data['height']) {
+ $data['height'] = $image->info['height'];
+ }
+ if (!$data['width_upcrop'] && $image->info['width'] < $data['width']) {
+ $data['width'] = $image->info['width'];
+ }
+
if (!imageapi_image_crop($image, $data['xoffset'], $data['yoffset'], $data['width'], $data['height'])) {
watchdog('imagecache', 'imagecache_crop failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
return FALSE;