- Issue created by @xmacinfo
- 🇨🇦Canada xmacinfo Canada
I tried clearing the cache a few times to no luck.
PHPStorm find the GD file with the proper function:
/Applications/PhpStorm.app/Contents/plugins/php-impl/lib/php.jar!/stubs/gd/gd.php
Using PHP Version 8.4.6 or PHP 8.3.16, Drupal Status Report PHP info has:
GD Support enabled
GD Version bundled (2.1.0 compatible) - 🇮🇳India Ishani Patel
Hello,
I've followed the steps and checked with D11.1.6, and using PHP Version 8.3.19
But not reproduce the issue.Thank you!
- 🇦🇺Australia mstrelan
You somehow have a php build that is missing the global imageavif function. What happens if you modify that line 565 to
$supported = function_exists('imageavif') && imageavif(imagecreatetruecolor(1, 1), $tempFile, 0, 10) && fstat($tempFile)['size'] > 0;
I linked to this issue from ✨ Let GDToolkit support AVIF image format Needs work . Yes it seems like Drupal should check whether the function exists before calling it.
- 🇫🇷France andypost
Not clear how it possible to by-pass guard
function_exists('imageavif')
maybe this function exists but disabled somehow I may be misunderstanding your comment but in Drupal there is not a
function_exists
check forimageavif
.- 🇨🇦Canada xmacinfo Canada
@ishani patel The bug affect only Drupal 11.2.x, not Drupal 11.1.x.
- Merge request !12254Fix "Call to undefined function Drupal\system\Plugin\ImageToolkit\imageavif()" → (Closed) created by cilefen
- 🇮🇹Italy mondrake 🇮🇹
Given that 📌 Use avif with webp fallback for all core image styles Active has practically made AVIF the default for 11.2, I think this will be Critical in case PHP is not binding the avif functions.
- 🇫🇷France Grimreaper France 🇫🇷
Hi,
I am encountering the same fatal error on an env without AVIF support.
On status report page, there is a warning about the missing AVIF support but this does not prevent the fatal error.
- 🇨🇦Canada xmacinfo Canada
@grimreaper
Indeed, now I see the status message error message:
bundled (2.1.0 compatible) - Supported image file formats: GIF, JPEG, PNG, WEBP. - Unsupported image file format: AVIF. Check the PHP GD installation documentation if you want to add support. - AVIF is not supported, likely because of PHP missing a codec for encoding images. See the change record for more information.
Not sure why I was not seeing this yesterday.
- 🇨🇦Canada xmacinfo Canada
My development stack does will not support AVIF for the foreseeable future. Fortunately, the production stack supports AVIF.
AVIF Support enabled
So, we need to make sure the fallback to WEBP works on all user create/edit paths:
admin/people/create
/user/edit
or
/user/1/edit
- 🇫🇷France andypost
This guard is required
/var/www/html/web $ php -r 'var_dump(function_exists("imageavif"));' bool(true) /var/www/html/web $ php -d disable_functions=imageavif -r 'var_dump(function_exists("imageavif"));' bool(false)
- 🇨🇦Canada xmacinfo Canada
Yes, but I do not see a fallback to WEBP.
$supported = function_exists('imageavif') && imageavif(imagecreatetruecolor(1, 1), $tempFile, 0, 10) && fstat($tempFile)['size'] > 0; fclose($tempFile); return $supported;
Are we returning FALSE instead of falling back to WEBP?
- 🇫🇷France andypost
@xmacinfo this method is for detection, see the commit from 📌 Use avif with webp fallback for all core image styles Active
- 🇦🇺Australia mstrelan
@xmacinfo this function is just a check to see if avif is supported. It is called by GDToolkit::supportedTypes and if it returns FALSE then we don't include avif as a supported type. The
image_convert_avif
plugin checks if avif is supported and creates an avif if it is, and a webp (or whatever else you configure) if not. Agree with the RTBC but would be good for @xmacinfo or @grimreaper to confirm it works with this patch. - 🇫🇷France Grimreaper France 🇫🇷
Hi,
I confirm the fix and RTBC on an environment without AVIF support, no more fatal error when displaying a form with an image field like /media/add/image
Thanks!
- 🇬🇧United Kingdom catch
Committed/pushed to 11.x and cherry-picked to 11.2.x, thanks!