public function ElevateZoomPlusManager::formElementAlter in ElevateZoom Plus 8
Same name and namespace in other branches
- 7 src/ElevateZoomPlusManager.php \Drupal\elevatezoomplus\ElevateZoomPlusManager::formElementAlter()
Implements hook_blazy_form_element_alter().
File
- src/
ElevateZoomPlusManager.php, line 100
Class
- ElevateZoomPlusManager
- Provides ElevateZoom Plus library methods mainly for hooks.
Namespace
Drupal\elevatezoomplusCode
public function formElementAlter(array &$form, array $definition = []) {
$field_type = isset($definition['field_type']) ? $definition['field_type'] : '';
$settings = $definition['settings'];
$texts = [
'link',
'string',
'string_long',
];
$applicable = $field_type && !in_array($field_type, $texts);
// Exclude from blazy text formatters, or blazy views grid.
if (empty($definition['no_image_style']) && !isset($settings['grouping'])) {
$elevatezoomplus = [
'#type' => 'select',
'#title' => $this
->t('ElevateZoom Plus'),
'#options' => $this
->getOptionsetOptions('elevatezoomplus'),
'#empty_option' => $this
->t('- None -'),
'#default_value' => isset($settings['elevatezoomplus']) ? $settings['elevatezoomplus'] : '',
'#description' => $this
->t('Choose an optionset.'),
'#weight' => -98.98999999999999,
'#enforce' => FALSE,
];
// Hooks into Blazy UI to support Blazy Filter.
if (isset($settings['admin_css'])) {
$form['extras']['#access'] = TRUE;
$form['extras']['elevatezoomplus'] = $elevatezoomplus;
$form['extras']['elevatezoomplus']['#default_value'] = isset($settings['extras']['elevatezoomplus']) ? $settings['extras']['elevatezoomplus'] : '';
$form['extras']['elevatezoomplus']['#description'] .= ' ' . $this
->t('Blazy/Splide/Slick Filter only. Warning! Not working nicely. This needs extra image styles which are lacking with inline images.');
}
else {
if ($applicable) {
$form['elevatezoomplus'] = $elevatezoomplus;
$form['elevatezoomplus']['#description'] .= ' ' . $this
->t('Requires any lightbox (<b>not: Image to iFrame, Image linked to content, Image rendered</b>) for <b>Media switcher</b> if using Splide/Slick with asNavFor. If not, be sure to choose only <b>Image to Elevatezoomplus</b>.');
if ($this->manager
->configLoad('admin_css', 'blazy.settings')) {
$form['closing']['#attached']['library'][] = 'elevatezoomplus/admin';
}
}
}
}
}