function masonry_library_info_alter in Masonry API 8
Implements hook_library_info_alter().
Masonry and Imagesloaded libraries may not be in the /libraries folder. MasonryService is capable of detecting that is a certain extend so we can correct the file path in both librarie declarations if needed.
File
- ./
masonry.module, line 72 - Provides the hooks implementation to interface with Libraries API.
Code
function masonry_library_info_alter(&$libraries, $extension) {
if ($extension == 'masonry') {
/** @var \Drupal\masonry\Services\MasonryService $masonryService */
$masonryService = \Drupal::service('masonry.service');
if ($masonryPath = $masonryService
->isMasonryInstalled()) {
$libraries['masonry']['js'] = [
"/{$masonryPath}" => [
'minified' => true,
],
];
}
if ($imagesLoaded = $masonryService
->isImagesloadedInstalled()) {
$libraries['imagesloaded']['js'] = [
"/{$imagesLoaded}" => [
'minified' => true,
],
];
}
}
}