public function BlazyFilter::buildSettings in Blazy 8.2
Same name and namespace in other branches
- 7 src/Plugin/Filter/BlazyFilter.php \Drupal\blazy\Plugin\Filter\BlazyFilter::buildSettings()
Returns the main settings.
Parameters
string $text: The provided text.
Return value
array The main settings for current filter.
Overrides BlazyFilterInterface::buildSettings
1 call to BlazyFilter::buildSettings()
- BlazyFilter::process in src/
Plugin/ Filter/ BlazyFilter.php - Performs the filter processing.
File
- src/
Plugin/ Filter/ BlazyFilter.php, line 227
Class
- BlazyFilter
- Provides a filter to lazyload image, or iframe elements.
Namespace
Drupal\blazy\Plugin\FilterCode
public function buildSettings($text) {
$settings = $this->settings + BlazyDefault::lazySettings();
$settings['_check_protocol'] = TRUE;
$settings['grid'] = stristr($text, 'data-grid') !== FALSE;
$settings['column'] = stristr($text, 'data-column') !== FALSE;
$settings['id'] = $settings['gallery_id'] = Blazy::getHtmlId('blazy-filter-' . Crypt::randomBytesBase64(8));
$settings['plugin_id'] = 'blazy_filter';
$settings['_grid'] = $settings['column'] || $settings['grid'];
$definitions = $this->entityFieldManager
->getFieldDefinitions('media', 'remote_video');
$settings['is_media_library'] = $definitions && isset($definitions['field_media_oembed_video']);
$settings['_resimage'] = $this->blazyManager
->getModuleHandler()
->moduleExists('responsive_image');
if (isset($settings['hybrid_style']) && ($style = $settings['hybrid_style'])) {
if ($settings['_resimage'] && ($box_style = $this->blazyManager
->entityLoad($style, 'responsive_image_style'))) {
$settings['responsive_image_style'] = $style;
}
else {
$settings['image_style'] = $style;
}
}
$this->blazyManager
->getCommonSettings($settings);
// Provides alter like formatters to modify at one go, even clumsy here.
$build = [
'settings' => $settings,
];
$this->blazyManager
->getModuleHandler()
->alter('blazy_settings', $build, $this->settings);
return array_merge($settings, $build['settings']);
}