public function RotateImageEffect::transformDimensions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php \Drupal\image\Plugin\ImageEffect\RotateImageEffect::transformDimensions()
Determines the dimensions of the styled image.
Parameters
array &$dimensions: Dimensions to be modified - an array with the following keys:
- width: the width in pixels, or NULL if unknown
- height: the height in pixels, or NULL if unknown
When either of the dimensions are NULL, the corresponding HTML attribute will be omitted when an image style using this image effect is used.
string $uri: Original image file URI. It is passed in to allow an effect to optionally use this information to retrieve additional image metadata to determine dimensions of the styled image. ImageEffectInterface::transformDimensions key objective is to calculate styled image dimensions without performing actual image operations, so be aware that performing IO on the URI may lead to decrease in performance.
Overrides ImageEffectBase::transformDimensions
File
- core/
modules/ image/ src/ Plugin/ ImageEffect/ RotateImageEffect.php, line 45 - Contains \Drupal\image\Plugin\ImageEffect\RotateImageEffect.
Class
- RotateImageEffect
- Rotates an image resource.
Namespace
Drupal\image\Plugin\ImageEffectCode
public function transformDimensions(array &$dimensions, $uri) {
// If the rotate is not random and the angle is a multiple of 90 degrees,
// then the new dimensions can be determined.
if (!$this->configuration['random'] && (int) $this->configuration['degrees'] == $this->configuration['degrees'] && $this->configuration['degrees'] % 90 == 0) {
if ($this->configuration['degrees'] % 180 != 0) {
$temp = $dimensions['width'];
$dimensions['width'] = $dimensions['height'];
$dimensions['height'] = $temp;
}
}
else {
$dimensions['width'] = $dimensions['height'] = NULL;
}
}