function image_rotate_dimensions

Image dimensions callback; Rotate.

Parameters

$dimensions: Dimensions to be modified - an array with components width and height, in pixels.

$data: An array of attributes to use when performing the rotate effect containing the following items:

  • "degrees": The number of (clockwise) degrees to rotate the image.
  • "random": A boolean indicating that a random rotation angle should be used for this image. The angle specified in "degrees" is used as a positive and negative maximum.
1 string reference to 'image_rotate_dimensions'
image_image_effect_info in modules/image/image.effects.inc
Implements hook_image_effect_info().

File

modules/image/image.effects.inc, line 301

Code

function image_rotate_dimensions(array &$dimensions, array $data) {
    // If the rotate is not random and the angle is a multiple of 90 degrees,
    // then the new dimensions can be determined.
    if (!$data['random'] && (int) $data['degrees'] == $data['degrees'] && $data['degrees'] % 90 == 0) {
        if ($data['degrees'] % 180 != 0) {
            $temp = $dimensions['width'];
            $dimensions['width'] = $dimensions['height'];
            $dimensions['height'] = $temp;
        }
    }
    else {
        $dimensions['width'] = $dimensions['height'] = NULL;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.