Problem/Motivation
Drupal 11 is compatible with the AVIF format by default. For this reason, field_image and field_media_image should include avif in their default allowed file extensions.
AVIF (AV1 Image File Format) is a modern image format that offers superior compression compared to JPEG, PNG, and even WebP, while maintaining high visual quality. It is now widely supported across modern browsers (Chrome, Firefox, Safari 16.4+, Edge).
Drupal previously added webp to the default allowed extensions for image fields, recognizing the importance of supporting modern formats out of the box. AVIF represents the next step in that progression.
Currently, the default file_extensions setting for image fields in Drupal core is png gif jpg jpeg webp. Site builders who want to allow AVIF uploads must manually update this setting through the UI or via configuration management, creating unnecessary friction.
This change meets the Drupal core feature request criteria:
- Usage: AVIF adoption is growing rapidly as the successor to WebP. Any Drupal site focused on performance and modern image delivery — which represents a substantial portion of the installed base — benefits directly from this change. Enabling AVIF by default encourages best practices for web performance (Core Web Vitals, LCP) without requiring site builders to know they need to opt in.
- Technical debt: The change is minimal — adding a single string token (
avif) to a few configuration files and one PHP method. It introduces no new procedures, no additional database queries, and no new abstractions. The cost is negligible compared to the performance benefit it unlocks for end users.
The relevant files are:
core/profiles/standard/config/install/field.field.node.article.field_image.ymlcore/profiles/standard/config/optional/field.field.media.image.field_media_image.ymlcore/modules/image/src/Plugin/Field/FieldType/ImageItem.php(field type defaults)
Steps to reproduce
- Install Drupal with the Standard profile.
- Navigate to Admin → Structure → Content types → Article → Manage fields → Image field settings.
- Observe that
avifis not included in the allowed file extensions. - Attempt to upload an
.avifimage to an Article node — it will be rejected.
Proposed resolution
Add avif to the default file_extensions value in:
field.field.node.article.field_image.ymlfield.field.media.image.field_media_image.yml- The
defaultFieldSettings()method inImageItem.php
Important caveat — server-side processing: Drupal's image toolkit (GD or ImageMagick) may not be able to process AVIF files for image styles on all hosting environments. GD requires PHP 8.1+ compiled with libavif. This means:
- Allowing the extension enables AVIF uploads and delivery of the original file.
- Image styles applied to AVIF files may fail silently on servers without AVIF support in the image toolkit.
This should be documented and ideally a follow-up issue should address toolkit capability detection, but it should not block adding the extension to the allowed list, consistent with how webp was handled.
Remaining tasks
- Confirm current browser support matrix for AVIF is sufficient for inclusion.
- Verify behavior of GD and ImageMagick toolkits when processing AVIF files in image styles.
- Write or update tests covering the new default.
- Determine if a
hook_update_N/ post-update hook is needed for existing sites (not just new installs). - Review whether the
demo_umamiprofile also needs updating.
User interface changes
The default value of the "Allowed file extensions" field in image field settings will include avif for new Drupal installations using the Standard profile. No UI changes to forms or labels.
Introduced terminology
None.
API changes
The return value of ImageItem::defaultFieldSettings() will include avif in the file_extensions string. This is a minor change and only affects new field instances created programmatically without explicitly setting file_extensions.
Data model changes
None. This only affects default configuration values, not the schema.
Release notes snippet
AVIF images can now be uploaded to image fields by default. Site builders no longer need to manually add avif to the allowed file extensions. Note that generating image styles from AVIF files requires PHP 8.1+ with libavif support enabled in the GD toolkit, or a compatible ImageMagick installation.
AI usage (if applicable)
[x] AI Assisted Issue
This issue was generated with AI assistance, but was reviewed and refined by the creator.
| Comment | File | Size | Author |
|---|---|---|---|
| allowed-file-extensions.png | 29.83 KB | cadence96 |
Issue fork drupal-3581280
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:
Comments
Comment #4
adhershmnair commentedComment #5
smustgrave commentedMay be overkill but think we should add a CR to announce a new default is being added.