function image_dimensions_max_size_crop in Image max size crop 7
Crop image dimensions when larger than specified dimensions.
The resulting dimensions can be smaller for one or both target dimensions.
Parameters
array $dimensions: Dimensions to be modified - an array with components width and height, in pixels.
int $width: The target width, in pixels. If this value is NULL then the cropping will be based only on the height value.
int $height: The target height, in pixels. If this value is NULL then the cropping will be based only on the width value.
Return value
bool TRUE if $dimensions was modified, FALSE otherwise.
2 calls to image_dimensions_max_size_crop()
- image_max_size_crop_dimensions in ./
image_max_size_crop.module - Image dimensions callback; Resize.
- image_max_size_crop_effect in ./
image_max_size_crop.module - Image effect callback; Resize an image resource.
File
- ./
image_max_size_crop.module, line 145 - Functions needed to create an image style.
Code
function image_dimensions_max_size_crop(array &$dimensions, $width = NULL, $height = NULL) {
// If desired dimensions are set, check if they are larger then
// image dimensions.
$old_width = $dimensions['width'];
$old_height = $dimensions['height'];
if ($width && $width < $dimensions['width']) {
$dimensions['width'] = $width;
}
if ($height && $height < $dimensions['height']) {
$dimensions['height'] = $height;
}
if ($dimensions['width'] == $old_width && $dimensions['height'] == $old_height) {
return FALSE;
}
return TRUE;
}