public function BlazyManagerBase::getIoSettings in Blazy 8.2
Same name and namespace in other branches
- 7 src/BlazyManagerBase.php \Drupal\blazy\BlazyManagerBase::getIoSettings()
Returns drupalSettings for IO.
Parameters
array $attach: The settings which determine what library to attach.
Return value
array The supported IO drupalSettings.
Overrides BlazyManagerInterface::getIoSettings
1 call to BlazyManagerBase::getIoSettings()
- BlazyManagerBase::attach in src/
BlazyManagerBase.php - Returns array of needed assets suitable for #attached property.
File
- src/
BlazyManagerBase.php, line 267
Class
- BlazyManagerBase
- Implements BlazyManagerInterface.
Namespace
Drupal\blazyCode
public function getIoSettings(array $attach = []) {
$io = [];
$thold = trim($this
->configLoad('io.threshold')) ?: '0';
$number = strpos($thold, '.') !== FALSE ? (double) $thold : (int) $thold;
$thold = strpos($thold, ',') !== FALSE ? array_map('trim', explode(',', $thold)) : [
$number,
];
// Respects hook_blazy_attach_alter() for more fine-grained control.
foreach ([
'enabled',
'disconnect',
'rootMargin',
'threshold',
] as $key) {
$default = $key == 'rootMargin' ? '0px' : FALSE;
$value = $key == 'threshold' ? $thold : $this
->configLoad('io.' . $key);
$io[$key] = isset($attach['io.' . $key]) ? $attach['io.' . $key] : ($value ?: $default);
}
return (object) $io;
}