public function BlazyFilter::settingsForm in Blazy 7
Same name and namespace in other branches
- 8.2 src/Plugin/Filter/BlazyFilter.php \Drupal\blazy\Plugin\Filter\BlazyFilter::settingsForm()
Implements callback_filter_settings().
File
- src/
Plugin/ Filter/ BlazyFilter.php, line 366
Class
- BlazyFilter
- Provides a filter to lazyload image, or iframe elements.
Namespace
Drupal\blazy\Plugin\FilterCode
public function settingsForm($form, &$form_state, $filter) {
$lightboxes = $this->manager
->getLightboxes();
$elements['filter_tags'] = [
'#type' => 'checkboxes',
'#title' => t('Enable HTML tags'),
'#options' => [
'img' => t('Image'),
'iframe' => t('Video iframe'),
],
'#default_value' => empty($filter->settings['filter_tags']) ? [] : array_values((array) $filter->settings['filter_tags']),
'#description' => t('To disable per item, add attribute <code>data-unblazy</code>.'),
];
$elements['grid'] = [
'#type' => 'checkbox',
'#title' => t('Grid Foundation'),
'#default_value' => $filter->settings['grid'],
];
$elements['column'] = [
'#type' => 'checkbox',
'#title' => t('CSS3 Masonry columns'),
'#default_value' => $filter->settings['column'],
'#description' => t('Check to support inline grids, or columns. Load both to support any, yet only one can exist at a time in a particular body text.'),
];
$elements['media_switch'] = [
'#type' => 'select',
'#title' => t('Media switcher'),
'#options' => [
'media' => t('Image to iframe'),
],
'#empty_option' => t('- None -'),
'#default_value' => $filter->settings['media_switch'],
'#description' => t('<ul><li><b>Image to iframe</b> will hide iframe behind image till toggled.</li><li><b>Image to lightbox</b> (Colorbox, Photobox, PhotoSwipe, Intense, etc.) requires a grid. Add <code>data-column="1 3 4"</code> or <code>data-grid="1 3 4"</code> to the first image/ iframe only.</li></ul>'),
];
if (!empty($lightboxes)) {
foreach ($lightboxes as $lightbox) {
$name = ucwords(str_replace('_', ' ', $lightbox));
$elements['media_switch']['#options'][$lightbox] = t('Image to @lightbox', [
'@lightbox' => $name,
]);
}
}
$elements['use_data_uri'] = [
'#type' => 'checkbox',
'#title' => t('Trust data URI'),
'#default_value' => isset($filter->settings['use_data_uri']) ? $filter->settings['use_data_uri'] : FALSE,
'#description' => t('Enable to support the use of data URI. Leave it unchecked if unsure, or never use data URI.'),
'#suffix' => t('Check out <a href="@url1">filter tips</a> for details. Be sure to configure Blazy pages <a href="@url2">here</a>.', [
'@url1' => url('filter/tips', [
'fragment' => 'filter-blazy_filter',
]),
'@url2' => url('admin/config/media/blazy', [
'fragment' => 'edit-visibility',
]),
]),
];
return $elements;
}