public function ImagecacheProportionsFormatter::settingsForm in Imagecache Proportions 8
Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form elements for the formatter settings.
Overrides ImageFormatter::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ ImagecacheProportionsFormatter.php, line 40 - Contains \Drupal\imagecache_proportions\Plugin\Field\FieldFormatter.
Class
- ImagecacheProportionsFormatter
- Plugin implementation of the 'imagecache_proportions' formatter.
Namespace
Drupal\imagecache_proportions\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, array &$form_state) {
$element = parent::settingsForm($form, $form_state);
$element['image_style']['#title'] = $this
->t('Select the squared style');
$element['image_style']['#weight'] = -2;
$image_styles = image_style_options(FALSE);
$element['image_style_portrait'] = array(
'#title' => $this
->t('Select the vertical style'),
'#type' => 'select',
'#default_value' => $this
->getSetting('image_style_portrait'),
'#empty_option' => t('None (original image)'),
'#options' => $image_styles,
'#weight' => -4,
);
$element['image_style_landscape'] = array(
'#title' => $this
->t('Select the horizontal style'),
'#type' => 'select',
'#default_value' => $this
->getSetting('image_style_landscape'),
'#empty_option' => t('None (original image)'),
'#options' => $image_styles,
'#weight' => -3,
);
$element['looseness'] = array(
'#type' => 'number',
'#size' => 10,
'#title' => $this
->t('Select the looseness to consider an image squared'),
'#description' => $this
->t('Number of pixels that a image can be wider than higher (or viceversa) to be considered squared.'),
'#default_value' => $this
->getSetting('looseness'),
'#weight' => -1,
);
return $element;
}