public function ImagickToolkit::buildConfigurationForm in Imagick 8
Form constructor.
Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElement.
Parameters
array $form: An associative array containing the initial structure of the plugin form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Return value
array The form structure.
Overrides PluginFormInterface::buildConfigurationForm
File
- src/
Plugin/ ImageToolkit/ ImagickToolkit.php, line 270
Class
- ImagickToolkit
- Defines the Imagick toolkit for image manipulation within Drupal.
Namespace
Drupal\imagick\Plugin\ImageToolkitCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['jpeg'] = [
'#type' => 'fieldset',
'#title' => $this
->t('JPEG specific settings'),
'#description' => $this
->t('<strong>Tip: </strong>Generated images can be converted to the JPEG format using the Convert effect.'),
];
$form['jpeg'][self::CONFIG_JPEG_QUALITY] = [
'#type' => 'number',
'#title' => $this
->t('Quality'),
'#description' => $this
->t('Higher values mean better image quality but bigger files. Quality level below 80% is not advisable when using ImageMagick.'),
'#min' => 0,
'#max' => 100,
'#default_value' => $this->configFactory
->get(self::CONFIG)
->get(self::CONFIG_JPEG_QUALITY),
'#field_suffix' => $this
->t('%'),
];
$form['jpeg'][self::CONFIG_OPTIMIZE] = [
'#type' => 'checkbox',
'#title' => t('Use Google Pagespeed Insights image optimization.'),
'#description' => t('See the <a href=":url" target="_blank">guidelines</a> for further information.', [
':url' => 'https://developers.google.com/speed/docs/insights/OptimizeImages',
]),
'#default_value' => $this->configFactory
->get(self::CONFIG)
->get(self::CONFIG_OPTIMIZE),
];
$form[self::CONFIG_RESIZE_FILTER] = [
'#type' => 'select',
'#title' => t('Imagic resize filter'),
'#description' => t('Define the resize filter for image manipulations. If you\'re not sure what you should enter here, leave the default settings.'),
'#options' => [
-1 => t('- None -'),
imagick::FILTER_UNDEFINED => 'FILTER_UNDEFINED',
imagick::FILTER_POINT => 'FILTER_POINT',
imagick::FILTER_BOX => 'FILTER_BOX',
imagick::FILTER_TRIANGLE => 'FILTER_TRIANGLE',
imagick::FILTER_HERMITE => 'FILTER_HERMITE',
imagick::FILTER_HANNING => 'FILTER_HANNING',
imagick::FILTER_HAMMING => 'FILTER_HAMMING',
imagick::FILTER_BLACKMAN => 'FILTER_BLACKMAN',
imagick::FILTER_GAUSSIAN => 'FILTER_GAUSSIAN',
imagick::FILTER_QUADRATIC => 'FILTER_QUADRATIC',
imagick::FILTER_CUBIC => 'FILTER_CUBIC',
imagick::FILTER_CATROM => 'FILTER_CATROM',
imagick::FILTER_MITCHELL => 'FILTER_MITCHELL',
imagick::FILTER_LANCZOS => 'FILTER_LANCZOS',
imagick::FILTER_BESSEL => 'FILTER_BESSEL',
imagick::FILTER_SINC => 'FILTER_SINC',
],
'#default_value' => $this->configFactory
->get(self::CONFIG)
->get(self::CONFIG_RESIZE_FILTER),
];
$form[self::CONFIG_STRIP_METADATA] = [
'#type' => 'checkbox',
'#title' => t('Strip images of all metadata.'),
'#description' => t('Eg. profiles, comments, ...'),
'#default_value' => $this->configFactory
->get(self::CONFIG)
->get(self::CONFIG_STRIP_METADATA),
];
return $form;
}