modules/thunder_media/src/Plugin/ImageEffect/AutoAspectEffect.php
public function applyEffect(ImageInterface $image) {
    $ratio_adjustment = isset($this->configuration['ratio_adjustment']) ? floatval($this->configuration['ratio_adjustment']) : 1;
    $aspect = $image->getWidth() / $image->getHeight();

    // Calculate orientation: width / height * adjustment. If > 1, it's wide.
    $style_name = (($aspect * $ratio_adjustment) > 1) ? $this->configuration['landscape'] : $this->configuration['portrait'];

    if (empty($style_name)) {
      // Do nothing. just return what we've got.
      return TRUE;
    }

    /* @var ImageStyle $style */
    $style = ImageStyle::load($style_name);
    if (empty($style)) {
      // Required preset has gone missing?
      return FALSE;
    }

    // Run the preset actions ourself.
    foreach ($style->getEffects() as $sub_effect) {
      /* @var ImageEffectInterface $sub_effect */
      $sub_effect->applyEffect($image);
    }
    return TRUE;
  }
public function applyEffect(ImageInterface $image) {
    $ratio_adjustment = isset($this->configuration['ratio_adjustment']) ? floatval($this->configuration['ratio_adjustment']) : 1;
    $aspect = $image->getWidth() / $image->getHeight();

    // Calculate orientation: width / height * adjustment. If > 1, it's wide.
    $style_name = (($aspect * $ratio_adjustment) > 1) ? $this->configuration['landscape'] : $this->configuration['portrait'];

    if (empty($style_name)) {
      // Do nothing. just return what we've got.
      return TRUE;
    }

    /* @var ImageStyle $style */
    $style = ImageStyle::load($style_name);
    if (empty($style)) {
      // Required preset has gone missing?
      return FALSE;
    }

    // Run the preset actions ourself.
    foreach ($style->getEffects() as $sub_effect) {
      /* @var ImageEffectInterface $sub_effect */
      $sub_effect->applyEffect($image);
    }
    return TRUE;
  }
public function applyEffect ( ImageInterface $ image ) { $ ratio_adjustment = isset ( $ this -> configuration [ 'ratio_adjustment' ] ) ? floatval ( $ this -> configuration [ 'ratio_adjustment' ] ) : 1 ; $ aspect = $ image -> getWidth ( ) / $ image -> getHeight ( ) ; // Calculate orientation: width / height * adjustment. If > 1, it's wide. $ style_name = ( ( $ aspect * $ ratio_adjustment ) > 1 ) ? $ this -> configuration [ 'landscape' ] : $ this -> configuration [ 'portrait' ] ; if ( empty ( $ style_name ) ) { // Do nothing. just return what we've got. return TRUE ; } /* @var ImageStyle $style */ $ style = ImageStyle :: load ( $ style_name ) ; if ( empty ( $ style ) ) { // Required preset has gone missing? return FALSE ; } // Run the preset actions ourself. foreach ( $ style -> getEffects ( ) as $ sub_effect ) { /* @var ImageEffectInterface $sub_effect */ $ sub_effect -> applyEffect ( $ image ) ; } return TRUE ; }
{@inheritdoc}
{