diff --git a/netbox/extras/forms/model_forms.py b/netbox/extras/forms/model_forms.py index f5833c334..dbcc8717a 100644 --- a/netbox/extras/forms/model_forms.py +++ b/netbox/extras/forms/model_forms.py @@ -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.") } diff --git a/netbox/extras/utils.py b/netbox/extras/utils.py index 761f4affb..45c0729a4 100644 --- a/netbox/extras/utils.py +++ b/netbox/extras/utils.py @@ -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('\\', '/')