diff --git a/shariff.install b/shariff.install
index 95cc75d..4f4f70c 100644
--- a/shariff.install
+++ b/shariff.install
@@ -11,14 +11,24 @@
function shariff_requirements($phase) {
$requirements = array();
+ // Check if library is available via libraries module.
+ if (function_exists('libraries_get_path')) {
+ $library_shariff = libraries_get_path('shariff');
+ }
+
+ $library_missing = [
+ 'title' => t('Shariff Library'),
+ 'description' => t('Please download at least v1.4.6 of the shariff library and place it in the Drupal root libraries folder. So that the js file is available under DRUPAL_ROOT/libraries/shariff/build/shariff.min.js.', [':url' => 'https://github.com/heiseonline/shariff/releases/latest']),
+ 'severity' => REQUIREMENT_ERROR,
+ 'value' => t('Library missing'),
+ ];
+
if ($phase == 'runtime') {
- if (!file_exists('libraries/shariff/build/shariff.min.js')) {
- $requirements['shariff_lib'] = [
- 'title' => t('Shariff Library'),
- 'description' => t('Please download at least v1.4.6 of the shariff library and place it in the Drupal root libraries folder. So that the js file is available under DRUPAL_ROOT/libraries/shariff/build/shariff.min.js.', [':url' => 'https://github.com/heiseonline/shariff/releases/latest']),
- 'severity' => REQUIREMENT_ERROR,
- 'value' => t('Library missing'),
- ];
+ if (!file_exists('libraries/shariff/build/shariff.min.js') && empty($library_shariff)) {
+ $requirements['shariff_lib'] = $library_missing;
+ }
+ elseif (empty($library_shariff)) {
+ $requirements['shariff_lib'] = $library_missing;
}
else {
$requirements['shariff_lib'] = [
diff --git a/shariff.module b/shariff.module
index c9db8a9..aa88b9e 100644
--- a/shariff.module
+++ b/shariff.module
@@ -246,3 +246,19 @@ function shariff_node_view(array &$build, EntityInterface $entity, EntityViewDis
);
}
}
+
+/**
+ * Implements hook_library_info_alter().
+ */
+function shariff_library_info_alter(&$libraries, $extension) {
+ if ($extension === 'shariff' && function_exists('libraries_get_path')) {
+
+ $libraries['shariff-min']['css']['component'] = ['/' . libraries_get_path('shariff') . '/build/shariff.min.css' => []];
+ $libraries['shariff-min']['js'] = ['/' . libraries_get_path('shariff') . '/build/shariff.min.js' => ['scope' => 'footer']];
+
+ $libraries['shariff-complete']['css']['component'] = ['/' . libraries_get_path('shariff') . '/build/shariff.complete.css' => []];
+ $libraries['shariff-complete']['js'] = ['/' . libraries_get_path('shariff') . '/build/shariff.complete.js' => ['scope' => 'footer']];
+
+ $libraries['shariff-naked']['js'] = ['/' . libraries_get_path('shariff') . '/build/shariff.complete.js' => ['scope' => 'footer']];
+ }
+}
\ No newline at end of file