Compare commits

...

1 Commits

Author SHA1 Message Date
Martin Hauser
acc7c4af9d feat(extras): Add AVIF support for image attachments
Extends allowed image file formats to include AVIF for better modern
format support. Updates form widgets to explicitly support AVIF in
Firefox with the `accept` attribute.

Fixes #21039
2026-01-15 21:21:25 +01:00
2 changed files with 6 additions and 2 deletions

View File

@@ -22,7 +22,7 @@ from utilities.forms.fields import (
DynamicModelMultipleChoiceField, JSONField, SlugField,
)
from utilities.forms.rendering import FieldSet, ObjectAttribute
from utilities.forms.widgets import ChoicesWidget, HTMXSelect
from utilities.forms.widgets import ChoicesWidget, ClearableFileInput, HTMXSelect
from utilities.tables import get_table_for_model
from virtualization.models import Cluster, ClusterGroup, ClusterType
@@ -784,6 +784,10 @@ class ImageAttachmentForm(forms.ModelForm):
fields = [
'image', 'name', 'description',
]
# Explicitly set 'image/avif' to support AVIF selection in Firefox
widgets = {
'image': ClearableFileInput(attrs={'accept': 'image/*,image/avif'}),
}
help_texts = {
'name': _("If no name is specified, the file name will be used.")
}

View File

@@ -78,7 +78,7 @@ def image_upload(instance, filename):
"""
upload_dir = 'image-attachments'
default_filename = 'unnamed'
allowed_img_extensions = ('bmp', 'gif', 'jpeg', 'jpg', 'png', 'webp')
allowed_img_extensions = ('avif', 'bmp', 'gif', 'jpeg', 'jpg', 'png', 'webp')
# Normalize Windows paths and create a Path object.
normalized_filename = str(filename).replace('\\', '/')