You are here

protected function AspectSwitcherImageEffect::getChildImageStyleToExecute in Image Effects 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageEffect/AspectSwitcherImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\AspectSwitcherImageEffect::getChildImageStyleToExecute()
  2. 8.2 src/Plugin/ImageEffect/AspectSwitcherImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\AspectSwitcherImageEffect::getChildImageStyleToExecute()

Gets the name of the child image style to process based on image aspect.

Parameters

int $width: The width of the image.

int $height: The height of the image.

Return value

string The name of the image style to process.

2 calls to AspectSwitcherImageEffect::getChildImageStyleToExecute()
AspectSwitcherImageEffect::applyEffect in src/Plugin/ImageEffect/AspectSwitcherImageEffect.php
Applies an image effect to the image object.
AspectSwitcherImageEffect::transformDimensions in src/Plugin/ImageEffect/AspectSwitcherImageEffect.php
Determines the dimensions of the styled image.

File

src/Plugin/ImageEffect/AspectSwitcherImageEffect.php, line 193

Class

AspectSwitcherImageEffect
Choose image styles to apply based on source image orientation.

Namespace

Drupal\image_effects\Plugin\ImageEffect

Code

protected function getChildImageStyleToExecute($width, $height) {
  $ratio_adjustment = isset($this->configuration['ratio_adjustment']) ? floatval($this->configuration['ratio_adjustment']) : 1;

  // Width / height * adjustment. If > 1, it's wide.
  return $width / $height * $ratio_adjustment > 1 ? $this->configuration['landscape_image_style'] : $this->configuration['portrait_image_style'];
}