diff --git a/netbox/extras/models.py b/netbox/extras/models.py index 485448336..06ed07b85 100644 --- a/netbox/extras/models.py +++ b/netbox/extras/models.py @@ -422,6 +422,16 @@ class ImageAttachment(models.Model): # before the request finishes. (For example, to display a message indicating the ImageAttachment was deleted.) self.image.name = _name + @property + def size(self): + """ + Wrapper around `image.size` to suppress an OSError in case the file is inaccessible. + """ + try: + return self.image.size + except OSError: + return None + # # User actions diff --git a/netbox/templates/inc/image_attachments.html b/netbox/templates/inc/image_attachments.html index 0f922f3c6..d467eb414 100644 --- a/netbox/templates/inc/image_attachments.html +++ b/netbox/templates/inc/image_attachments.html @@ -7,12 +7,12 @@