public function BlazyManagerBase::getIoSettings in Blazy 7
Same name and namespace in other branches
- 8.2 src/BlazyManagerBase.php \Drupal\blazy\BlazyManagerBase::getIoSettings()
Returns drupalSettings for IO.
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 150
Class
- BlazyManagerBase
- Implements BlazyManagerInterface.
Namespace
Drupal\blazyCode
public function getIoSettings(array $attach = []) {
if (!isset($this->isIoSettings)) {
$thold = trim($this
->config('io.threshold', '0', 'blazy.settings'));
$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
->config('io.' . $key, $default);
$io[$key] = isset($attach['io.' . $key]) ? $attach['io.' . $key] : $value;
}
// Prevents drupal_array_merge_deep from duplicating threshold values.
$this->isIoSettings = (object) $io;
}
return $this->isIoSettings;
}