You are here

protected function UriDependentTestImageEffect::getUriDependentDimensions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/image/tests/modules/image_module_test/src/Plugin/ImageEffect/UriDependentTestImageEffect.php \Drupal\image_module_test\Plugin\ImageEffect\UriDependentTestImageEffect::getUriDependentDimensions()

Make the image dimensions dependent on the image file extension.

Parameters

string $uri: Original image file URI.

Return value

array Associative array.

  • width: Integer with the derivative image width.
  • height: Integer with the derivative image height.
2 calls to UriDependentTestImageEffect::getUriDependentDimensions()
UriDependentTestImageEffect::applyEffect in core/modules/image/tests/modules/image_module_test/src/Plugin/ImageEffect/UriDependentTestImageEffect.php
Applies an image effect to the image object.
UriDependentTestImageEffect::transformDimensions in core/modules/image/tests/modules/image_module_test/src/Plugin/ImageEffect/UriDependentTestImageEffect.php
Determines the dimensions of the styled image.

File

core/modules/image/tests/modules/image_module_test/src/Plugin/ImageEffect/UriDependentTestImageEffect.php, line 49
Contains \Drupal\image_module_test\Plugin\ImageEffect\UriDependentTestImageEffect.

Class

UriDependentTestImageEffect
Performs an image operation that depends on the URI of the original image.

Namespace

Drupal\image_module_test\Plugin\ImageEffect

Code

protected function getUriDependentDimensions($uri) {
  $dimensions = [];
  $extension = pathinfo($uri, PATHINFO_EXTENSION);
  switch (strtolower($extension)) {
    case 'png':
      $dimensions['width'] = $dimensions['height'] = 100;
      break;
    case 'gif':
      $dimensions['width'] = $dimensions['height'] = 50;
      break;
    default:
      $dimensions['width'] = $dimensions['height'] = 20;
      break;
  }
  return $dimensions;
}