Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Although there's no error path. The css and js file (video.js / video-js.min.css / video-js.css) doesn't load in the drupal content page.
and no script for alternate flash player;
Drupal 7.2.8 / video.js module 7.x2.3 / video-js-4.6.3 library
Comment | File | Size | Author |
---|---|---|---|
#5 | videojs-enable_sitewide_option-2288533-5.patch | 1008 bytes | PascalAnimateur |
Comments
Comment #1
sebcolor CreditAttribution: sebcolor commentedI do the upgrade to version 7.x-3.0-alpha2+9-dev… And it's fixed up ! Sorry ;-)
Comment #2
huteb CreditAttribution: huteb commentedHi,
I have the same problem. More precisely, everything loads fine after emptying the cache, but in subsequent page reloads the js/css are not added.
It actually seems that the "videojs_preprocess_videojs" function is not called after the first page load. I deactivated all cache in the performance settings and tester as admin and anonymous, always the same issue.
I tried v2.x, 3.x and the latest dev and reproduce at each time.
Comment #3
Jody LynnThe problem is that the css/js is added in videojs_field_formatter_view which is not a safe place to add these. The results of this function will get cached by page cache or, in case you are embedding the video within formatted text, in filter cache.
I suppose this is why so many drupal modules simply add their css/js to every page in hook_init.
I worked around it by adding videojs_add(); within a hook_node_view (or use hook_init) in a custom module.
Comment #4
mglamanThe current implementation is right and uses #attached. Also CSS/JS shouldn't be added on init because it'll bypass caching too many times.
This issue is definitely occurring when using Media + WYSIWYG. The body field's output is saved to cache_field. The entire HTML output for the Video.js inline video is saved in the cache. When the node (or other entity supporting field cache) is loaded, this output is pulled in. The function drupal_render isn't run which means the theming layer is skipped (because we have a cached output.)
It seems that if you'd like to support Video.js (or any other library required within Media + WYSIWYG) you'll need to manually add the library on hook_page_build or hook_entity_view (if you want to keep it specific.)
Comment #5
PascalAnimateur CreditAttribution: PascalAnimateur commentedThe mediaelement module has an option to enable it site wide (always load the js and css files), which would fix this issue but takes up extra bandwidth on pages without videos in them.
Here's a patch that implements that for videojs while we wait for media_wysiwyg to detect/inject attached js and css files to the fields when building the cache.