Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-85159

TinyMCE embed multimedia language mismatch

    • MOODLE_404_STABLE, MOODLE_405_STABLE, MOODLE_500_STABLE, MOODLE_501_STABLE
    • MDL-85159-404
    • MDL-85159-405
    • MDL-85159-500
    • MDL-85159-main
    • Hide

      Preparation

      1. Download the attached media file sample-video.webm.
      2. Download the attached vtt file sample-subtitle.vtt.

      Note: You can repeat the following tests on "Captions", "Descriptions", "Chapters" and "Metadata" using the same vtt file.

      Testing 1: Backward compatibility test (Main and 500)

      1. Do not checkout the patch yet.
      2. Login as admin
      3. Go to edit profile
      4. In description area where there is a tinymce editor, click on "Multimedia" to add a media file
      5. Click on the dropzone area to select the file and dd the downloaded media file
      6. Once the media is previewed, click on "Subtitles and captions" to add the subtitle
      7. Go to "Subtitles" tab to add the downloaded subtitle
      8. Set the language from the languages installed list "en"
      9. Set the label to "English"
      10. Click "Save" to insert the media into the tinymce editor.
      11. Click "Update profile" to save the changes
      12. Play the uploaded video and hover the "cc" for the available subtitles
      13. Verify that you see "english" is listed and it is working when enabled
      14. Apply the patch and go back to edit profile page
      15. Click on the media to select and click on "Multimedia" to edit
      16. Once the media is previewed, click on the "Subtitles and captions" and go to "Subtitles" tab
      17. Verify that the language is populated with "English (en)" based on the previously selected language.
      18. Verify that the language list is not listed as language codes but language names.

      Testing 1: Backward compatibility test (405 and 404)

      1. Do not checkout the patch yet.
      2. Login as admin
      3. Go to edit profile
      4. In description area where there is a tinymce editor, click on "Multimedia" to add a media file
      5. Go to "Video" tab and add the downloaded media file in "Video source URL"
      6. Click on "Subtitles and captions"
      7. Add the downloaded subtitle in "Subtitle track URL"
      8. Set the language from the languages installed list "en"
      9. Set the label to "English"
      10. Click "Insert media" to insert the media into the tinymce editor.
      11. Click "Update profile" to save the changes
      12. Play the uploaded video and hover the "cc" for the available subtitles
      13. Verify that you see "english" is listed and it is working when enabled
      14. Apply the patch and go back to edit profile page
      15. Click on the media to select and click on "Multimedia" to edit
      16. Click on "Subtitles and captions"
      17. Verify that the language is populated with "English (en)" based on the previously selected language.
      18. Verify that the language list is not listed as language codes but language names.

      Test 2: Fix accessibility issue (continue from step #18)

      1. Click on "Save" to update the media in the editor
      2. Click on "Update profile"
      3. Play the uploaded video and hover the "cc" for the available subtitles
      4. Verify that you still see "english" is listed and it is working when enabled
      5. View the page source code, copy them all and paste in html validator then click "Check"
      6. Once the results are generated search for "srclang"
      7. Verify that you don't see warning like in the following screenshot
      Show
      Preparation Download the attached media file sample-video.webm . Download the attached vtt file sample-subtitle.vtt . Note : You can repeat the following tests on "Captions", "Descriptions", "Chapters" and "Metadata" using the same vtt file . Testing 1: Backward compatibility test (Main and 500) Do not checkout the patch yet. Login as admin Go to edit profile In description area where there is a tinymce editor, click on "Multimedia" to add a media file Click on the dropzone area to select the file and dd the downloaded media file Once the media is previewed, click on "Subtitles and captions" to add the subtitle Go to "Subtitles" tab to add the downloaded subtitle Set the language from the languages installed list "en" Set the label to "English" Click "Save" to insert the media into the tinymce editor. Click "Update profile" to save the changes Play the uploaded video and hover the "cc" for the available subtitles Verify that you see "english" is listed and it is working when enabled Apply the patch and go back to edit profile page Click on the media to select and click on "Multimedia" to edit Once the media is previewed, click on the "Subtitles and captions" and go to "Subtitles" tab Verify that the language is populated with "English (en)" based on the previously selected language. Verify that the language list is not listed as language codes but language names. Testing 1: Backward compatibility test (405 and 404) Do not checkout the patch yet. Login as admin Go to edit profile In description area where there is a tinymce editor, click on "Multimedia" to add a media file Go to "Video" tab and add the downloaded media file in "Video source URL" Click on "Subtitles and captions" Add the downloaded subtitle in "Subtitle track URL" Set the language from the languages installed list "en" Set the label to "English" Click "Insert media" to insert the media into the tinymce editor. Click "Update profile" to save the changes Play the uploaded video and hover the "cc" for the available subtitles Verify that you see "english" is listed and it is working when enabled Apply the patch and go back to edit profile page Click on the media to select and click on "Multimedia" to edit Click on "Subtitles and captions" Verify that the language is populated with "English (en)" based on the previously selected language. Verify that the language list is not listed as language codes but language names. Test 2: Fix accessibility issue (continue from step #18) Click on "Save" to update the media in the editor Click on "Update profile" Play the uploaded video and hover the "cc" for the available subtitles Verify that you still see "english" is listed and it is working when enabled View the page source code, copy them all and paste in html validator then click "Check" Once the results are generated search for "srclang" Verify that you don't see warning like in the following screenshot
    • Hide

      Code verified against automated checks with warnings.

      Checked MDL-85159 using repository: https://github.com/stevandoMoodle/moodle.git

      Should these errors be fixed?

      Built on: Wed May 14 05:33:46 UTC 2025

      Show
      Code verified against automated checks with warnings. Checked MDL-85159 using repository: https://github.com/stevandoMoodle/moodle.git MOODLE_404_STABLE (0 errors / 19 warnings) [branch: MDL-85159-404 | CI Job ] overview (0/1) , phplint (0/0) , phpcs (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/0) , externalbackup (0/0) , grunt (0/0) , shifter (0/0) , mustache (0/18) , gherkin (0/0) , Warn: The MDL-85159 -404 branch at https://github.com/stevandoMoodle/moodle.git has not been rebased recently (>20 days ago). MOODLE_405_STABLE (0 errors / 18 warnings) [branch: MDL-85159-405 | CI Job ] overview (0/0) , phplint (0/0) , phpcs (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/0) , externalbackup (0/0) , grunt (0/0) , shifter (0/0) , mustache (0/18) , gherkin (0/0) , MOODLE_500_STABLE (0 errors / 0 warnings) [branch: MDL-85159-500 | CI Job ] main (0 errors / 0 warnings) [branch: MDL-85159-main | CI Job ] Should these errors be fixed? Built on: Wed May 14 05:33:46 UTC 2025
    • Hide

      Launching automatic jobs for branch MDL-85159-404

      Launching automatic jobs for branch MDL-85159-405

      Launching automatic jobs for branch MDL-85159-500

      Launching automatic jobs for branch MDL-85159-main

      Built on: Wed May 14 06:25:25 UTC 2025

      Show
      Launching automatic jobs for branch MDL-85159 -404 https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/19341/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66075/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66076/ Behat (Firefox - boost) Launching automatic jobs for branch MDL-85159 -405 https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/19342/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66077/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66078/ Behat (Firefox - boost) Launching automatic jobs for branch MDL-85159 -500 https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/19343/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66079/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66228/ Behat (Firefox - boost) Launching automatic jobs for branch MDL-85159 -main https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/19344/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66081/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66226/ Behat (Firefox - boost) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66227/ Behat (Firefox - classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66084/ App tests (stable app version) Built on: Wed May 14 06:25:25 UTC 2025
    • 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

      1. 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)
      2. 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)
      3. Create a Page ressource in you Moodle installation
      4. In the Page content, click on "Multimedia" to insert a video
      5. Upload the downloaded video file
      6. In the subtitles, upload the vtt file
        1. Select "en" as the Language
        2. Insert "English" as the Label
      7. Click on "Insert media"
      8. Save and display the page
      9. Validate the page HTML
        1. 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.

       

        1. image-2025-04-10-08-11-09-560.png
          image-2025-04-10-08-11-09-560.png
          32 kB
        2. image-2025-04-15-07-59-33-344.png
          image-2025-04-15-07-59-33-344.png
          92 kB
        3. image-2025-04-15-08-01-31-110.png
          image-2025-04-15-08-01-31-110.png
          131 kB
        4. image-2025-04-15-08-03-53-472.png
          image-2025-04-15-08-03-53-472.png
          168 kB
        5. img-2.png
          img-2.png
          50 kB
        6. img-3.png
          img-3.png
          720 kB
        7. sample-subtitle.vtt
          0.9 kB
        8. sample-video.webm
          5.04 MB
        9. testing.png
          testing.png
          248 kB

            stevani.andolo@moodle.com Stevani Andolo
            yveshelie Yves Hélie
            David Woloszyn David Woloszyn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 days, 2 hours, 41 minutes
                2d 2h 41m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.