Commit 762e8154 authored by Berdir's avatar Berdir Committed by Primsi
Browse files

Issue #2643902 by Berdir: Libraries module should (optionally?) be used to detect path to libraries

parent 1cc43f1d
......@@ -12,7 +12,12 @@ function dropzonejs_requirements($phase) {
$requirements = [];
if (!file_exists(DRUPAL_ROOT . '/libraries/dropzone/dist/dropzone.js')) {
$path = DRUPAL_ROOT . '/libraries/dropzone/dist/dropzone.js';
if (\Drupal::moduleHandler()->moduleExists('libraries')) {
$path = libraries_get_path('dropzone') . '/dist/dropzone.js';
}
if (!file_exists($path)) {
$requirements['dropzonejs_library'] = array(
'title' => t('Dropzone library missing'),
'description' => t('Dropzonejs requires the dropzone.js library.
......
......@@ -57,3 +57,12 @@ function template_preprocess_dropzonejs(&$variables) {
$variables['uploaded_files'] = $element['uploaded_files'];
}
/**
* Implements hook_library_info_alter().
*/
function dropzonejs_library_info_alter(&$libraries, $extension) {
if ($extension == 'dropzonejs' && \Drupal::moduleHandler()->moduleExists('libraries')) {
$libraries['dropzonejs']['js'] = ['/' . libraries_get_path('dropzone') . '/dist/min/dropzone.min.js' => []];
$libraries['dropzonejs']['css']['component'] = ['/' . libraries_get_path('dropzone') . '/dist/min/dropzone.min.css' => []];
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment