Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I spent some unwanted time last week debugging why a library I was adding had a uri like /Aites/all/modules/foo/bar.js> when using hook_library() and #attached['library'] in Drupal 7.
The reason is because I was specifying the library like this:
'js' => array(
'foo.js',
),
What hook_library() actually wants is this:
'js' => array(
'foo.js' => array(),
),
I think we could check for string vs. array there and just add the file if that's all you want. The Aites site effect doesn't immediately suggest that you've got the format wrong, it just looks like an invisible typo and there's no PHP error thrown or similar.
Comments
Comment #1
nod_Happened to me more than once as well. Hopefully #1996238: Replace hook_library_info() by *.libraries.yml file will "solve" this.
Comment #2
Wim LeersIndeed, happened to me many times as well.
Comment #15
quietone CreditAttribution: quietone at PreviousNext commentedSo, hook_library became hook_library_alter #1286868: Rename hook_library() and hook_library_alter() to standard pattern and hook_libray_alter was removed in #2392717: Remove hook_library_alter() from theme.api.php. And #1 points to an issue that was to fix this problem and the lack of any more discussion in the past 11 years supports that.
I am closing as outdated.