-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.4.7, 4.5.4, 5.0, 5.1
-
2
-
Team Hedgehogs 2025 Sprint 2.0, Team Hedgehogs 2025 Sprint 2.1, Team Hedgehogs 2025 Sprint 2.2
-
Small
In the TinyMCE editor, when a user wants to add an embed multimedia with subtitles, the language selector displays inversed language code and language label.
The wrong value is then inserted in the <track> HTML tag, causing accessibility issues in the media player.
<video title="[Redacted]" |
poster="[Redacted]" |
controls="controls" width="1920" height="1080"> |
<source
|
src="[Redacted].mp4"> |
<track kind="subtitles" src="[Redacted].chapters.en.vtt" |
srclang="English (en)" label="English"> </video> |
When using a screen reader, the lang attribute of the subtitles is not valid per HTML standards.
Problem found in 4.4.7+, investigated on a clean install of 5.0rc2.
Solution :
In /lib/editor/tiny/plugins/media/amd/src/embed/embedhelpers.js, in the prepareMoodleLang() function, swap the lang and code positions in the mapping logic for the installed and available variables (lines 227 and 233).
In fact, the tiny_media/embed/metadata/subtitles template seems to be semantically ok with the object structure received; the values are only inversed in the prepareMoodleLang() function.
Steps to reproduce
- Download video file from https://github.com/iandevlin/iandevlin.github.io/blob/master/mdn/video-player-with-captions/video/sintel-short.webm (Download raw file)
- Download vtt file from https://github.com/iandevlin/iandevlin.github.io/blob/master/mdn/video-player-with-captions/subtitles/vtt/sintel-en.vtt (Download raw file)
- Create a Page ressource in you Moodle installation
- In the Page content, click on "Multimedia" to insert a video
- Upload the downloaded video file
- In the subtitles, upload the vtt file
- Select "en" as the Language
- Insert "English" as the Label
- Click on "Insert media"
- Save and display the page
- Validate the page HTML
- The attribute srclang attribute of the track element is not valid.
- The attribute srclang attribute of the track element is not valid.
The error is caused by the language selector at step 6.1, where the value attribute and <option> innerHTML should be inverted.
Once inserted in the editor, the <video> tag contains the <track> tag, which has "Anglais" (the localized language name) as srclang value.