We know that WordPress provides native AVIF support as of version 6.5. If you are using ready-made WordPress installations from services like Vultr or DigitalOcean, you will most likely be able to upload images with AVIF extension without any problems.

However, if you are using a web hosting control panel like DirectAdmin, we have a small problem. This is because PHP 8.x versions installed with DirectAdmin are not compiled with AVIF support. To solve this problem, you need to make a small change and recompile PHP 8.2, 8.3 or 8.4. Here are the instructions:
How to add AVIF support to WordPress using PHP 8.4
System specifications: Ubuntu 24, DirectAdmin 1.673, PHP 8.4, WordPress 6.7.
- Log in to DirectAdmin as admin.
- Go to CustomBuild under Extra Features and then to Compilation.

- Find the PHP 8.4 section here and click Customize.

- In this step, add the –with-avif \ line below the –enable-gd \ and save
- Go back to CustomBuild and enter Build.

- In the last step, click Build and recompile PHP 8.4 with AVIF support. It will take 5-10 minutes depending on the server speed.
- After the installation is finished, enter the WordPress admin page. Here, click on the Info tab by following the Tools – Site Health path.

- Expand the Media Handling section and you will see that AVIF support is enabled.