Commit 4d5dcc26 authored by quicksketch's avatar quicksketch

#786950: Add support for ImageAPI when scaling to fit within max dimensions.

parent 894255af
......@@ -762,9 +762,15 @@ function filefield_validate_image_resolution(&$file, $maximum_dimensions = 0, $m
$errors[] = t('The image must be exactly %dimensions pixels.', array('%dimensions' => $maximum_dimensions));
}
// Check that scaling won't drop the image below the minimum dimensions.
elseif (image_get_toolkit() && (($info['width'] * $ratio < $min_width) || ($info['height'] * $ratio < $min_height))) {
elseif ((image_get_toolkit() || module_exists('imageapi')) && (($info['width'] * $ratio < $min_width) || ($info['height'] * $ratio < $min_height))) {
$errors[] = t('The image will not fit between the dimensions of %min_dimensions and %max_dimensions pixels.', array('%min_dimensions' => $minimum_dimensions, '%max_dimensions' => $maximum_dimensions));
}
// Try resizing the image with ImageAPI if available.
elseif (module_exists('imageapi') && imageapi_default_toolkit()) {
$res = imageapi_image_open($file->filepath);
imageapi_image_scale($res, $max_width, $max_height);
imageapi_image_close($res, $file->filepath);
}
// Try to resize the image to fit the dimensions.
elseif (image_get_toolkit() && @image_scale($file->filepath, $file->filepath, $max_width, $max_height)) {
drupal_set_message(t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $maximum_dimensions)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment