Преглед изворни кода

Fixes #9634: Respect image URLs which are already fully formed

For local storage, URLs will always be relative, but some custom storage backends
such as S3 may return absolute ones.
Stephen Muth пре 3 година
родитељ
комит
3d475e5afa
1 измењених фајлова са 10 додато и 2 уклоњено
  1. 10 2
      netbox/dcim/svg.py

+ 10 - 2
netbox/dcim/svg.py

@@ -113,8 +113,12 @@ class RackElevationSVG:
 
         # Embed front device type image if one exists
         if self.include_images and device.device_type.front_image:
+            url = device.device_type.front_image.url
+            # Convert any relative URLs to absolute
+            if url.startswith('/'):
+                url = '{}{}'.format(self.base_url, url)
             image = drawing.image(
-                href='{}{}'.format(self.base_url, device.device_type.front_image.url),
+                href=url,
                 insert=start,
                 size=end,
                 class_='device-image'
@@ -139,8 +143,12 @@ class RackElevationSVG:
 
         # Embed rear device type image if one exists
         if self.include_images and device.device_type.rear_image:
+            url = device.device_type.rear_image.url
+            # Convert any relative URLs to absolute
+            if url.startswith('/'):
+                url = '{}{}'.format(self.base_url, url)
             image = drawing.image(
-                href='{}{}'.format(self.base_url, device.device_type.rear_image.url),
+                href=url,
                 insert=start,
                 size=end,
                 class_='device-image'