Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
in Q2A Core by
I can't upload .webp image format in Q2A website. Please tell me, Where to define .webp image format to upload images.
Q2A version: 1.8.6

1 Answer

0 votes

The supported image file types are defined in the function qa_upload_file() (located in qa-include/app/upload.php). To allow upload of .webp files you need to override (basically re-implement) that function in a custom plugin.

Changing core files is discouraged, so do not edit the original file. Your modifications would be lost when you update Q2A and you would have to re-apply them.

I don't think that just allowing the upload is sufficient, though. I expect you'll also need set the proper content type (image/webp) for the uploaded files to be displayed correctly. The respective code seems to be located in qa-include/qa-blob.php and currently only supports JPEG, PNG, GIF, PDF and Flash, and defaults to application/octet-stream for everything else. AFAICS that code doesn't support overriding, so you would have to resort to modifying a core file there (which, again, is not recommended).

A pull request can be given to core right?
"A pull request can be given to core right?"

@GATEOverflow Probably. But I'm not familiar enough with the code to be able to judge if that file listed in my answer is the only place that would need to be updated.
Also, if that code is being touched anyway, it would be desirable to not hard-code content types in the first place. A better way might be to put a list of supported types in the database and read it from there, so that an admin could (more or less) easily add/remove uploadable file types.