diff --git a/netbox/extras/models/models.py b/netbox/extras/models/models.py
index fc69e692c..d687aa821 100644
--- a/netbox/extras/models/models.py
+++ b/netbox/extras/models/models.py
@@ -9,6 +9,8 @@ from django.core.validators import ValidationError
from django.db import models
from django.urls import reverse
from django.utils import timezone
+from django.utils.html import escape
+from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from rest_framework.utils.encoders import JSONEncoder
@@ -728,6 +730,18 @@ class ImageAttachment(ChangeLoggedModel):
def filename(self):
return os.path.basename(self.image.name).split('_', 2)[2]
+ @property
+ def html_tag(self):
+ """
+ Returns a complete
tag suitable for embedding in an HTML document.
+ """
+ return mark_safe('
'.format(
+ url=self.image.url,
+ height=self.image_height,
+ width=self.image_width,
+ alt_text=escape(self.description or self.name),
+ ))
+
@property
def size(self):
"""