You are here

protected function AspectSwitcherImageEffect::failSafeGetImageStyle 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::failSafeGetImageStyle()
  2. 8.2 src/Plugin/ImageEffect/AspectSwitcherImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\AspectSwitcherImageEffect::failSafeGetImageStyle()

Gets an image style object.

Parameters

string $image_style_name: The name of the image style to get.

Return value

\Drupal\image\Entity\ImageStyle|null|false The image style object, or NULL if the name is NULL, or FALSE if the image style went missing from the db.

6 calls to AspectSwitcherImageEffect::failSafeGetImageStyle()
AspectSwitcherImageEffect::applyEffect in src/Plugin/ImageEffect/AspectSwitcherImageEffect.php
Applies an image effect to the image object.
AspectSwitcherImageEffect::buildConfigurationForm in src/Plugin/ImageEffect/AspectSwitcherImageEffect.php
Form constructor.
AspectSwitcherImageEffect::calculateDependencies in src/Plugin/ImageEffect/AspectSwitcherImageEffect.php
Calculates dependencies for the configured plugin.
AspectSwitcherImageEffect::getSummary in src/Plugin/ImageEffect/AspectSwitcherImageEffect.php
Returns a render array summarizing the configuration of the image effect.
AspectSwitcherImageEffect::transformDimensions in src/Plugin/ImageEffect/AspectSwitcherImageEffect.php
Determines the dimensions of the styled image.

... See full list

File

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

Class

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

Namespace

Drupal\image_effects\Plugin\ImageEffect

Code

protected function failSafeGetImageStyle($image_style_name) {
  if ($image_style_name === NULL) {
    return NULL;
  }
  $image_style = ImageStyle::load($image_style_name);
  if ($image_style === NULL) {

    // Required style has gone missing?
    $this->logger
      ->error("Cannot find image style '%style_name' to execute an 'aspect switcher' effect.", [
      '%style_name' => $image_style_name,
    ]);
    return FALSE;
  }
  return $image_style;
}