public function ImagefieldSlideshowFieldFormatter::settingsForm in Imagefield Slideshow 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 FormatterBase::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ ImagefieldSlideshowFieldFormatter.php, line 121
Class
- ImagefieldSlideshowFieldFormatter
- Plugin implementation of 'imagefield_slideshow_field_formatter' formatter.
Namespace
Drupal\imagefield_slideshow\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$image_styles = image_style_options(FALSE);
$description_link = Link::fromTextAndUrl($this
->t("Configure Image Styles"), Url::fromRoute('entity.image_style.collection'));
$element['imagefield_slideshow_style'] = [
'#title' => t("Image style"),
'#type' => 'select',
'#default_value' => $this
->getSetting('imagefield_slideshow_style'),
'#empty_option' => t("None (original image)"),
'#options' => $image_styles,
'#description' => $description_link
->toRenderable() + [
'#access' => $this->currentUser
->hasPermission('administer image styles'),
],
];
$effects = [
'none' => 'none',
// 'blindX' => 'blindX',
// 'blindY' => 'blindY',
// 'blindZ' => 'blindZ',
// 'cover' => 'cover',
// 'curtainX' => 'curtainX',
// 'curtainY' => 'curtainY',
'fade' => 'fade',
'fadeout' => 'fadeout',
// 'fadeZoom' => 'fadeZoom',
// 'growX' => 'growX',
// 'growY' => 'growY',
// 'scrollUp' => 'scrollUp',
// 'scrollDown' => 'scrollDown',
// 'scrollLeft' => 'scrollLeft',
// 'scrollRight' => 'scrollRight',
'scrollHorz' => 'scrollHorz',
// 'scrollVert' => 'scrollVert',
// 'shuffle' => 'shuffle',
// 'slideX' => 'slideX',
// 'slideY' => 'slideY',
// 'toss' => 'toss',
// 'turnUp' => 'turnUp',
// 'turnDown' => 'turnDown',
// 'turnLeft' => 'turnLeft',
// 'turnRight' => 'turnRight',
// 'uncover' => 'uncover',
// 'wipe' => 'wipe',
// 'zoom' => 'zoom',
'flipHorz' => 'flipHorz',
'flipVert' => 'flipVert',
'shuffle' => 'shuffle',
];
$element['imagefield_slideshow_style_effects'] = [
'#type' => 'select',
'#title' => t("Effect"),
'#options' => $effects,
'#default_value' => $this
->getSetting('imagefield_slideshow_style_effects'),
'#description' => t("The transition effect that will be used to change between images. Not all options below may be relevant depending on the effect. <a href='http://jquery.malsup.com/cycle/browser.html' target='_black'>Follow this link to see examples of each effect.</a>"),
];
$image_pause = [
'true' => "Yes",
'false' => "No",
];
$element['imagefield_slideshow_style_pause'] = [
'#title' => t("Image pause"),
'#type' => 'select',
'#default_value' => $this
->getSetting('imagefield_slideshow_style_pause'),
'#options' => $image_pause,
'#description' => t("Should image be paused on hover."),
];
$element['imagefield_slideshow_prev_next'] = [
'#title' => $this
->t("Enable Prev & Next button"),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('imagefield_slideshow_prev_next'),
'#description' => $this
->t('This will show the Prev and Next button for slideshow.'),
];
$range0 = array_combine(range(100, 1000, 100), range(100, 1000, 100));
$range1 = array_combine(range(2000, 10000, 1000), range(2000, 10000, 1000));
$transition_speed = array_replace($range0, $range1);
$element['imagefield_slideshow_transition_speed'] = [
'#type' => 'select',
'#title' => t("Transition Speed"),
'#options' => $transition_speed,
'#default_value' => $this
->getSetting('imagefield_slideshow_transition_speed'),
'#description' => t("The transition speed between images."),
];
$range3 = array_combine(range(0, 1000, 100), range(0, 1000, 100));
$timeout = array_replace($range3, $range1);
$element['imagefield_slideshow_timeout'] = [
'#type' => 'select',
'#title' => t("Timeout"),
'#options' => $timeout,
'#default_value' => $this
->getSetting('imagefield_slideshow_timeout'),
'#description' => t("The timeout for slides."),
];
$element['imagefield_slideshow_pager'] = [
'#title' => $this
->t("Enable Pager ?"),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('imagefield_slideshow_pager'),
'#description' => $this
->t('This will show the Pager on slideshow.'),
];
return $element;
}