Problem/Motivation
The media library view mode for Rijksvideo uses the .rijksvideo wrapper and attaches the rijksvideo/rijksvideo library, but its markup is a simple native <video controls> preview. It does not include the custom player element .rijksvideo__video (the video currently uses the legacy class .rijksvideo-element).
rijksvideo.js selects every .rijksvideo element and initialises the custom Video player, which then tries to set volume (and related plugins) on a missing .rijksvideo__video node. That throws a JavaScript error. In AJAX contexts (for example editing a paragraph that embeds Rijksvideo, or opening the media library) this can break the form/dialog instead of only failing the preview.
Steps to reproduce
- Install and enable Rijksvideo (2.x / 2.0.0-alpha7 or later).
- Create one or more Rijksvideo media items.
- Open the media library (for example when selecting media on a content type), or edit an entity/paragraph that shows a Rijksvideo media-library preview via AJAX.
- Inspect the browser console (and the AJAX response if the form fails).
- Observe a JavaScript error from the custom player when it runs against media-library markup that has
.rijksvideobut no.rijksvideo__video.
Proposed resolution
-
Update
media--rijksvideo--media-library.html.twigso the media library preview no longer uses the custom player root class or library:- Remove
attach_library('rijksvideo/rijksvideo'). - Replace the wrapper class
.rijksvideowith.rijksvideo-media-library. - Rename the video class from
.rijksvideo-elementto.rijksvideo-media-library__video. - Keep native
controlsand keep displaying{{ name }}.
- Remove
-
In
rijksvideo.js, skip initialising the custom player when.rijksvideo__videois missing, so incomplete or non-player wrappers cannot crash volume/plugin setup. -
Leave the default Rijksvideo display template unchanged (
.rijksvideo+.rijksvideo__video) so the full accessible player keeps working.
Remaining tasks
- Confirm the default (non–media-library) Rijksvideo player still works (play, volume, captions, etc.).
- Confirm media library preview uses native controls, shows the media name, and produces no console errors.
- Confirm AJAX paragraph / entity edit with a Rijksvideo preview no longer crashes.
User interface changes
Media library Rijksvideo items continue to show a native HTML5 video preview with controls and the media name. The custom Rijksvideo chrome is no longer initialised on that view mode. The default front-end / full media display is unchanged.
API changes
None.
Data model changes
None.
Issue fork rijksvideo-3634295
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 #4
erwinvb commented