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

Allow .webp file extension by default

XMLWordPrintable

    • MOODLE_402_STABLE, MOODLE_403_STABLE, MOODLE_404_STABLE
    • MOODLE_500_STABLE
    • MDL-81437_allow-webp-file-extension-by-default
    • Hide

      Adding the following to your config.php:

      $CFG->customfiletypes = [
          (object)[
              'extension' => 'webp',
              'icon' => 'png',
              'type' => 'image/webp',
              'groups' => ['image', 'web_image', 'optimised_image'],
              'string' => 'image'
          ]
      ]; 

      Show
      Adding the following to your config.php: $CFG->customfiletypes = [ (object)[ 'extension' => 'webp' , 'icon' => 'png' , 'type' => 'image/webp' , 'groups' => [ 'image' , 'web_image' , 'optimised_image' ], 'string' => 'image' ] ];
    • Hide

      The new ad-hoc task and the utility function in the upgradelib are both covered by unit tests.

      Before patch

      1. Log in as administrator
      2. Under "Administration → Plugins → Repositories → Manage repositories" set Legacy course files to "Enabled and visible"
      3. Under "Administration → Plugins → Repositories → Common repository settings" set "Legacy course files in new courses" to "Yes".
      4. Under "Administration → Courses → Default settings → Course default settings" set Legacy course files to "Yes".
      5. Add a new course.
      6. Go to "More → Legacy course files"
      7. Upload file_example_WEBP_50kB.webp
      8. Note the file icon has the question mark.

      After patch

      1. Update to this code, run an upgrade, run cron.
      2. Re-visit the course "Legacy files" section
      3. Verify the file has now the image icon.
      4. Go to "Site administration" → "Server" → "File types"
      5. Verify webp is there and listed as any other image file type, e.g. tiff.
      Show
      The new ad-hoc task and the utility function in the upgradelib are both covered by unit tests. Before patch Log in as administrator Under "Administration → Plugins → Repositories → Manage repositories" set Legacy course files to "Enabled and visible" Under "Administration → Plugins → Repositories → Common repository settings" set "Legacy course files in new courses" to "Yes". Under "Administration → Courses → Default settings → Course default settings" set Legacy course files to "Yes". Add a new course. Go to "More → Legacy course files" Upload file_example_WEBP_50kB.webp Note the file icon has the question mark. After patch Update to this code, run an upgrade, run cron. Re-visit the course "Legacy files" section Verify the file has now the image icon. Go to "Site administration" → "Server" → "File types" Verify webp is there and listed as any other image file type, e.g. tiff.
    • Hide

      Code verified against automated checks.

      Checked MDL-81437 using repository: https://github.com/ziegenberg/moodle

      More information about this report

      Built on: Mon Mar 31 15:27:00 UTC 2025

      Show
      Code verified against automated checks. Checked MDL-81437 using repository: https://github.com/ziegenberg/moodle main (0 errors / 0 warnings) [branch: MDL-81437_allow-webp-file-extension-by-default | CI Job ] More information about this report Built on: Mon Mar 31 15:27:00 UTC 2025
    • Show
      Launching automatic jobs for branch MDL-81437 -main https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/18464/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/63231/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/63232/ Behat (Firefox - boost) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/63233/ Behat (Firefox - classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/63234/ App tests (stable app version) --> unrelated failure, please ignore. Built on: Fri Mar 7 06:25:59 UTC 2025

      Currently .webp files are not accepted for file upload by default. It is an optimized file format, specifically designed for web, shouldn't it just be allowed by default?

       

      I'm thinking we just add it to the following array:

      https://github.com/moodle/moodle/blob/4da813d35e421c818579b3fb811cb56d822120c7/lib/classes/filetypes.php#L47

        1. file_example_WEBP_50kB.webp
          49 kB
        2. before.png
          before.png
          16 kB
        3. after.png
          after.png
          16 kB
        4. 5.sm.webp
          11 kB
        5. 4.sm.webp
          20 kB
        6. 3.sm.webp
          17 kB
        7. 2.sm.webp
          22 kB
        8. 1.sm.webp
          10 kB

            Daniel Ziegenberg Daniel Ziegenberg
            frederikmillingpytlick Frederik Milling Pytlick
            Luca Bösch Luca Bösch
            Paul Holden Paul Holden
            Stevani Andolo Stevani Andolo
            Votes:
            4 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 46 minutes
                46m

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