Problem/Motivation
Not all servers support converting to AVIF, so we can't use it as a default format for image styles in install profiles.
Steps to reproduce
- Have a server that doesn't support AVIF
- Use the Convert image style plugin configured to use AVIF
- Create an article with an image, the image will not display
Proposed resolution
As per #3372932-40: [Meta] High-performance images (nearly) out of the box we may need a new Image Effect to convert to AVIF if it's supported, with a fallback to WEBP if it's not. Possibly this could be generic for other formats too, but for now only AVIF has explicit requirements.
Remaining tasks
- Decide if we want to do this
- Review the approach in the MR
- Make the IS and CR sparkle
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3510582
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3510582-avif-with-fallback
changes, plain diff MR !11361
Comments
Comment #3
mstrelan commentedQuick PoC of an image effect with fallback format. Setting to NR for feedback on the approach, please don't send it back for tests/lint/CR etc.
Comment #4
mstrelan commentedAdded a test for when AVIF is supported and another test for the fallback. Added a draft CR. This is ready for review.
Comment #5
smustgrave commentedCould the IS get some love. Wouldn't this be considered an API change?
Wonder if a CR is required?
Comment #6
mstrelan commentedUpdated the IS to hopefully make it clearer. There is already a CR, are you suggesting it might not be necessary? I think it is useful.
Comment #7
mstrelan commentedComment #8
mstrelan commentedRe #5:
It's a new plugin, not a change to an existing one, so no breakage here. You could argue the change to the protected function in GDToolkit is a BC break, but plugins are considered internal and it's a protected method as well, so I don't think it's an issue.
Comment #9
andypostI find it good/handy feature with CR)
Moreover AVIF is specifically good for big sizes with fallback
Comment #10
catchNot necessarily in this issue, could maybe be a follow-up, would we want to consider some kind of configurable filesize threshold where below a certain point we always skip AVIF and use webp instead? Have seen various discussions that decoding AVIF in the browser is a lot more expensive than webp, which can undo the bandwidth savings with smaller images.
Comment #11
smustgrave commentedOpened up #3516434: Consider falling back to webp from AVIF based on filesize for that discussion.
Comment #12
catchOne comment on the MR.
Comment #13
mstrelan commentedSwitched to keyvalue instead of state
Comment #14
catchLooks good.
Comment #15
poker10 commentedSorry for asking, maybe it is obvious, but when we added webp format and possible conversion to core and image styles (#3275557: Add webp image conversion to core's install profile's image style and #3406267: All core shipped image styles should include webp conversion), we have not added any fallback. Was webp available in all PHP installations at that time? If not, are we sure that now when avif will not be available, webp will be?
Comment #16
catch@poker10 I am fairly sure that PHP installation support was widespread when webp was added to core. imagewebp from the gd library has been available since PHP 5.4 according to https://www.php.net/manual/en/function.imagewebp.php so theoretically that means it was everywhere.
However there was also an issue that older versions of osx, from around 2015 and earlier would not render webp, regardless of browser. This delayed us enabling webp by default in image styles in core until some time during Drupal 10. So we had it available as an option for a long time before then.
With AVIF it has been somewhat the opposite, in that all the browsers we care about supported it before php did. So once we do this issue, we should be able to convert the default image styles in core and Drupal CMS over, give or take the size considerations in the follow-up.
Comment #17
catchTagging for 11.2.0 release highlights, I'll try to review this one more time. Mine was the last RTBC on this issue but not the first two, so I think I'm fine to commit this still.
Comment #20
catchCommitted/pushed to 11.x and cherry-picked to 11.2.x, thanks!
Comment #22
catch