Problem/Motivation
We have for some years now been overriding H5P styling in Drupal 8, 9, and 10 using a simple custom module that splices in some extra CSS and we have been able to re-style H5P interactions very successful significantly.
The custom module was very simple...
function custom_h5p_overrides_h5p_styles_alter(&$styles, $libraries, $mode) {
$styles[] = (object) [
// Path relative to drupal root
'path' => \Drupal::service('extension.list.module')->getPath('custom_h5p_overrides') . '/css/custom-h5p-overrides.min.css','version' => '?ver=1'
];
}For example, we re-style a multiple choice question like this...

But since updating to 2.0.0-alpha5, the custom CSS deems no longer to be applied and we are right back where we started...

Can anyone please help us to understand what has changed here and why this very long-standing and reliable method no longer works?
Many thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | mutiple-scripts-and-styles.patch | 1.11 KB | pjotr.savitski |
| #6 | styles_alter-3526331-6.patch | 1.4 KB | anzi31 |
| h5p_after_module_update_AFTER.png | 22.63 KB | sirclickalot | |
| h5p_after_module_update_BEFORE.png | 21.52 KB | sirclickalot |
Issue fork h5p-3526331
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
filburt commentedHi,
please try with added type declarations - worked for me:
Comment #3
anzi31 commentedHave the same issue using D11. Neither 2.0.0-alpha5 nor 2.0.0-alpha6 works. Tried #2, but that did not help.
Debugging shows that the hook is not being called. Worked in D10 alpha4.
Comment #4
sirclickalot@anzi31, Agreed, the hook is simply not being called and #2 could not really make any difference.
We do love H5P for educational project but forward-compatibility of this module just does not seem to me to be going to happen so we are finding ourselves look around for other alternatives.
Comment #5
anzi31 commentedLooks like \Drupal::moduleHandler()->alter() was removed from H5PDefaultFormatter.php.
If you embed a quiz, it works, but if it is an iframe, it does not.
Comment #6
anzi31 commentedUploaded the wrong file.
Comment #7
illeace commentedWhat I found using Drupal 11 and 2.0.0-alpha6 is that my H5P CSS customizations worked when viewing the H5P embed link, and also were visible when editing the H5P, but not when viewing the node directly. After applying this patch, I also see those CSS customizations when viewing the node. I'm marking this RTBC.
Comment #8
sim_1Comment #11
sim_1Merged and marking as fixed. Thanks everyone for working on this and testing!
Comment #13
pjotr.savitski commentedOnly the first script and style would be added by the
and
Alter hooks could potentially add multiple scripts/styles and the solution should probably use array merge to add all the scripts/styles to existing ones.
The code should be
and
This is another issue altogether, but the absolute URL to the style and script does not include the version data. This means that browsers may not refresh the file contents even if the version data point is changed. That is how new aggregatedAssets method handled the provided data.
Comment #14
pjotr.savitski commentedThis should fix the issue with just one script/style being added.
Comment #15
sim_1Thank you so much, @pjotr.savitski for finding that issue. Reopening for testing.
Comment #17
illeace commentedI've review the patch from @pjotr.savitski and confirmed:
I've created a new feature branch / MR in the Issue fork, which is ready to merge.
Comment #19
sim_1Great, thanks! Merged second MR and re-marking as fixed.