Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CropImageEffect.php

function CropImageEffect::buildConfigurationForm

Overrides ResizeImageEffect::buildConfigurationForm

File

core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php, line 60

Class

CropImageEffect
Crops an image resource.

Namespace

Drupal\image\Plugin\ImageEffect

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildConfigurationForm($form, $form_state);
    $form['anchor'] = [
        '#type' => 'radios',
        '#title' => $this->t('Anchor'),
        '#options' => [
            'left-top' => $this->t('Top left'),
            'center-top' => $this->t('Top center'),
            'right-top' => $this->t('Top right'),
            'left-center' => $this->t('Center left'),
            'center-center' => $this->t('Center'),
            'right-center' => $this->t('Center right'),
            'left-bottom' => $this->t('Bottom left'),
            'center-bottom' => $this->t('Bottom center'),
            'right-bottom' => $this->t('Bottom right'),
        ],
        '#theme' => 'image_anchor',
        '#default_value' => $this->configuration['anchor'],
        '#description' => $this->t('The part of the image that will be retained during the crop.'),
    ];
    return $form;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal