public function ImageFormatter::settingsForm in Facebook Instant Articles 8.2
Same name and namespace in other branches
- 3.x src/Plugin/Field/FieldFormatter/ImageFormatter.php \Drupal\fb_instant_articles\Plugin\Field\FieldFormatter\ImageFormatter::settingsForm()
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/ ImageFormatter.php, line 91
Class
- ImageFormatter
- Plugin implementation of the 'fbia_image' formatter.
Namespace
Drupal\fb_instant_articles\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element['image_style'] = [
'#title' => $this
->t('Image style'),
'#type' => 'select',
'#default_value' => $this
->getSetting('image_style'),
'#empty_option' => t('None (original image)'),
'#options' => image_style_options(),
];
$element['caption'] = [
'#type' => 'checkbox',
'#description' => $this
->t('The caption uses the alt text of the image field.'),
'#title' => $this
->t('Enable caption'),
'#default_value' => $this
->getSetting('caption'),
];
$element['presentation'] = [
'#type' => 'select',
'#title' => $this
->t('Presentation'),
'#default_value' => $this
->getSetting('presentation'),
'#options' => [
Image::ASPECT_FIT => $this
->presentationLabel(Image::ASPECT_FIT),
Image::ASPECT_FIT_ONLY => $this
->presentationLabel(Image::ASPECT_FIT_ONLY),
Image::FULLSCREEN => $this
->presentationLabel(Image::FULLSCREEN),
Image::NON_INTERACTIVE => $this
->presentationLabel(Image::NON_INTERACTIVE),
],
'#empty_option' => $this
->t('None'),
];
return $element;
}