deleteImageEffect example

public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) {
    $this->imageStyle = $image_style;
    $this->imageEffect = $this->imageStyle->getEffect($image_effect);

    return parent::buildForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->imageStyle->deleteImageEffect($this->imageEffect);
    $this->messenger()->addStatus($this->t('The image effect %name has been deleted.', ['%name' => $this->imageEffect->label()]));
    $form_state->setRedirectUrl($this->imageStyle->toUrl('edit-form'));
  }

}
    $this->assertFileDoesNotExist($generated_uri);
    $this->drupalGet($this->getAbsoluteUrl($url));
    $this->assertSession()->statusCodeEquals(200);
    $this->assertFileExists($generated_uri);
    $image_file = $image_factory->get($generated_uri);
    // @todo Uncomment this once     // https://www.drupal.org/project/drupal/issues/2670966 is resolved.     // $this->assertEquals(41, $image_file->getWidth());     // $this->assertEquals(41, $image_file->getHeight());
    $effect_plugin = $style->getEffect($effect_id);
    $style->deleteImageEffect($effect_plugin);

    // Ensure that an effect can unset dimensions.     $effect = [
      'id' => 'image_module_test_null',
      'data' => [],
      'weight' => 8,
    ];

    $style->addImageEffect($effect);
    $style->save();
    $this->assertEquals('<img src="' . $url . '" alt="" />', $this->getImageTag($variables));

    
Home | Imprint | This part of the site doesn't use cookies.