I’m using MODX 2.8.7 with PHP 8.1, and I’m having trouble with AVIF images. I can upload AVIF files and use them on my site without any issues, but the Media Manager doesn’t show previews for these images. It’s making it tricky to manage and pick the right images.
Has anyone else experienced this? I’m wondering if there’s a setting I need to change or something else I might be missing. Thanks a lot!
I’m not sure if the problem is the phpThumb library.
You could try using PHP 8.2.
MODX uses the PHP function getimagesize and in the documentation it says:
Version 8.2.0
Now returns the actual image dimensions, bits and channels of AVIF images; previously, the dimensions were reported as 0x0, and bits and channels were not reported at all.
I’ve just tried with PHP 8.2, and the result is the same.
If I’m not mistaken, avif should be supported from version 8.1.
PS.
I have found some errors in my log
…model/phpthumb/phpthumb.class.php : 4460) PHP warning: imagecreatefromstring(): No AVIF support in this PHP build
…model/phpthumb/modphpthumb.class.php : 182) Error outputting thumbnail:
OutputThumbnail() failed because !is_resource($this->gdimg_output) in file “phpthumb.class.php” on line 702
Edit 2
I think the issue is not with Modx, but with the hosting itself. Still looking into it…
Image support in PHP is part of gd and Imagick libraries. It’s pretty common for those libraries to not be updated regularly. For years no new image formats came about, then we had webp and avif in a relatively short span. While support’s been there for a while, it’s not available everywhere yet. It’s dependent on the version of Imagick and gd libraries more than the PHP version. Then on the MODX side the phpThumb library shipped with Revo.
Another option if you’re stuck with your host is something like an image proxy service that will cache and transform the images at the edge rather than on the server. You uplaod whatever your server can handle and the proxy will transform and deliver the most efficient version of the image the client browser can handle. Cloudflare does this as do other services from the likes of ShortPixel.
Carlo I’m itching to use AVIF myself but my web host doesn’t support it yet. It’s not just the version of PHP it also depends on whether AVIF has been compiled into PHP.
In the MODX dashboard you can look at “Manage > Reports > System Info”, then click ‘view’ next to phpinfo. If you see the build flag ‘–with-avif’ then you are OK. If you don’t but you see for example ‘–with-webp’ then your PHP does not include AVIF support.
If it does include ‘–with-avif’ then your problem must be somewhere else.