Allow webp files to be uploaded

Allow webp files to be uploaded

by Paolo Oprandi -
Number of replies: 4
Hi,

I am trying to allow webp files to be uploaded to our Moodle install.

I have added it to the list of "File types" from the Site administration and am trying to add it as a course image, but I am still getting the following error:

Filetype error
I am afraid my Moodle version is 3.8.9 (we will be upgrading shortly).

Any help gratefully received.

Thanks, Paolo
(added same question to the resources course)
Average of ratings: -
In reply to Paolo Oprandi

Re: Allow webp files to be uploaded

by Ken Task -
Picture of Particularly helpful Moodlers
https://www.keycdn.com/support/optimus/configuration-to-deliver-webp

Assuming apache server ...
MIME type
#
If you have any issues with WebP showing up, ensure that the MIME type, image/webp is enabled on your server. On Apache you can add the following code to your .htaccess file - not providing cause don't think it will matter in future Moodles - see below.

In /etc/mime.types
has entries like:
image/png                                       png

Add
image/webp                    webp

And, when you get to version 4 of moodle, all of that may not make a difference if using a link to a file as the new UX/UI doen't use those mimetypes/icons but a generic file icon for all mimetypes.

However, if using a link to a file that opens in new window, image does display rather than downloading.

Tested with a version 4.0.5+ of Moodle ... no longer have a 3.8.x.
For others who would like to tinker themselves, attached is a 1.webp file.  Here in these forums, that file will download.

'SoS', Ken

Note: attempted insert using editor in forums and using insert image file it failed to accept. :|

Attachment 1.webp
In reply to Ken Task

Re: Allow webp files to be uploaded

by Paolo Oprandi -
Thanks for replying, Ken.

The problem is not that it is that webp aren't showing up - although that might also be a problem - it is that I cannot upload them as a course image (I haven't tried anywhere else), despite having added them as an allowed filetype.

The other thing is that we are using nginx and not apache for some reason. I do however have a mime.types file in the etc folder so I can try adding webp to that and see if it makes a difference.

Thanks - I'll report back if it makes a difference.
In reply to Paolo Oprandi

Re: Allow webp files to be uploaded

by Paolo Oprandi -
Hi Ken,
It seems I need to add it as an allowed mime type and update the "Course image file extensions" settings. No need to add the mime type to /etc/mime.types
Thanks again!
Average of ratings: Useful (2)
In reply to Paolo Oprandi

Re: Allow webp files to be uploaded

by Ken Task -
Picture of Particularly helpful Moodlers
Ahhh ....  in Appearance Courses
Course image file extensions courseoverviewfilesext
A comma-separated list of allowed course image file extensions.
So besides defining in mime types one also had to add:
,.webp
to the default .jpg,.gif,.png like:
.jpg,.gif,.png,.webp

Boy, is that kinda a 'needle' in haystack?   Thanks for sharing back! smile

Did you upgrade your 3.8 to a 4?

'SoS', Ken

Average of ratings: Useful (4)