protected function BlazyManager::createPlaceholder in Blazy 8.2
Same name and namespace in other branches
- 7 src/BlazyManager.php \Drupal\blazy\BlazyManager::createPlaceholder()
Build thumbnails, also to provide placeholder for blur effect.
1 call to BlazyManager::createPlaceholder()
- BlazyManager::thumbnailAndPlaceholder in src/
BlazyManager.php - Build thumbnails, also to provide placeholder for blur effect.
File
- src/
BlazyManager.php, line 413
Class
- BlazyManager
- Implements a public facing blazy manager.
Namespace
Drupal\blazyCode
protected function createPlaceholder(array &$settings, $style = NULL, $path = '') {
if (empty($path) && ($style = $this
->entityLoad('thumbnail', 'image_style')) && BlazyUtil::isValidUri($settings['uri'])) {
$path = $style
->buildUri($settings['uri']);
}
if ($path && BlazyUtil::isValidUri($path)) {
// Ensures the thumbnail exists before creating a dataURI.
if (!is_file($path) && $style) {
$style
->createDerivative($settings['uri'], $path);
}
// Overrides placeholder with data URI based on configured thumbnail.
if (is_file($path)) {
$settings['placeholder_fx'] = 'data:image/' . pathinfo($path, PATHINFO_EXTENSION) . ';base64,' . base64_encode(file_get_contents($path));
// Prevents double animations.
$settings['use_loading'] = FALSE;
}
}
}