2 * Implements hook_library_info_alter().
4 function {{ machine_name }}_library_info_alter(&$libraries, $extension) {
5 // Update Farbtastic to version 2.0.
6 if ($extension == 'core' && isset($libraries['jquery.farbtastic'])) {
7 // Verify existing version is older than the one we are updating to.
8 if (version_compare($libraries['jquery.farbtastic']['version'], '2.0', '<')) {
9 // Update the existing Farbtastic to version 2.0.
10 $libraries['jquery.farbtastic']['version'] = '2.0';
11 // To accurately replace library files, the order of files and the options
12 // of each file have to be retained; e.g., like this:
13 $old_path = 'assets/vendor/farbtastic';
14 // Since the replaced library files are no longer located in a directory
15 // relative to the original extension, specify an absolute path (relative
16 // to DRUPAL_ROOT / base_path()) to the new location.
17 $new_path = '/' . drupal_get_path('module', 'farbtastic_update') . '/js';
20 $old_path . '/farbtastic.js' => $new_path . '/farbtastic-2.0.js',
22 foreach ($libraries['jquery.farbtastic']['js'] as $source => $options) {
23 if (isset($replacements[$source])) {
24 $new_js[$replacements[$source]] = $options;
27 $new_js[$source] = $options;
30 $libraries['jquery.farbtastic']['js'] = $new_js;