You are here

public function ImageStyle::transformDimensions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/image/src/Entity/ImageStyle.php \Drupal\image\Entity\ImageStyle::transformDimensions()

Determines the dimensions of this image style.

Stores the dimensions of this image style into $dimensions associative array. Implementations have to provide at least values to next keys:

  • width: Integer with the derivative image width.
  • height: Integer with the derivative image height.

Parameters

array $dimensions: Associative array passed by reference. Implementations have to store the resulting width and height, in pixels.

string $uri: Original image file URI. It is passed in to allow effects to optionally use this information to retrieve additional image metadata to determine dimensions of the styled image. ImageStyleInterface::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 ImageStyleInterface::transformDimensions

See also

ImageEffectInterface::transformDimensions

File

core/modules/image/src/Entity/ImageStyle.php, line 312
Contains \Drupal\image\Entity\ImageStyle.

Class

ImageStyle
Defines an image style configuration entity.

Namespace

Drupal\image\Entity

Code

public function transformDimensions(array &$dimensions, $uri) {
  foreach ($this
    ->getEffects() as $effect) {
    $effect
      ->transformDimensions($dimensions, $uri);
  }
}