Front Images in Racks not shown when using S3 storage #4035

Closed
opened 2025-12-29 18:32:43 +01:00 by adam · 0 comments
Owner

Originally created by @ingvaldlorentzen on GitHub (Aug 27, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.7.9
  • NetBox version: v2.8.9

Steps to Reproduce

  1. Add a Device Type with front and read images using an on-prem S3 storage backend
  2. Add Device of that type to a Rack
  3. View Rack with "Show Images" checked

Expected Behavior

The front and rear images for the device is show in the rack.

Observed Behavior

Only the rear image is show.

The issue seems to be that the front image URL gets the base URL prepended (red line).
Inspecting the front device image from a rack in a browser:
image

While the back does not prepend the base URL and works as expected:
image

This seems to be be rooted in the difference between the following lines of code:
https://github.com/netbox-community/netbox/blob/develop/netbox/dcim/elevations.py#L97
and
https://github.com/netbox-community/netbox/blob/develop/netbox/dcim/elevations.py#L110

The _draw_device_rear function simply sets the url to device.device_type.rear_image.url while the _draw_device_front function sets the url to '{}{}'.format(self.base_url, device.device_type.front_image.url)

I'll gladly submit at PR that changes line 97 to work the same as line 110, but would like to hear if there is a reason these differ or if it's just a little bug.

Also I've only tested this with S3 storage backend, so not sure if my suggested change would affect other storage backends or if other storage backends are affected by this bug.

Originally created by @ingvaldlorentzen on GitHub (Aug 27, 2020). Originally assigned to: @jeremystretch on GitHub. ### Environment * Python version: `3.7.9` * NetBox version: `v2.8.9` ### Steps to Reproduce 1. Add a Device Type with front and read images using an on-prem S3 storage backend 2. Add Device of that type to a Rack 3. View Rack with "Show Images" checked <!-- What did you expect to happen? --> ### Expected Behavior The front and rear images for the device is show in the rack. <!-- What happened instead? --> ### Observed Behavior Only the rear image is show. The issue seems to be that the front image URL gets the base URL prepended (red line). Inspecting the front device image from a rack in a browser: <img width="852" alt="image" src="https://user-images.githubusercontent.com/8466369/91424137-b4b95680-e859-11ea-97d2-06ccaaead4ce.png"> While the back does not prepend the base URL and works as expected: <img width="844" alt="image" src="https://user-images.githubusercontent.com/8466369/91424240-d4507f00-e859-11ea-8efa-405398bf8d70.png"> This seems to be be rooted in the difference between the following lines of code: https://github.com/netbox-community/netbox/blob/develop/netbox/dcim/elevations.py#L97 and https://github.com/netbox-community/netbox/blob/develop/netbox/dcim/elevations.py#L110 The `_draw_device_rear` function simply sets the `url` to `device.device_type.rear_image.url` while the `_draw_device_front` function sets the `url` to `'{}{}'.format(self.base_url, device.device_type.front_image.url)` I'll gladly submit at PR that changes line `97` to work the same as line `110`, but would like to hear if there is a reason these differ or if it's just a little bug. Also I've only tested this with S3 storage backend, so not sure if my suggested change would affect other storage backends or if other storage backends are affected by this bug.
adam added the type: bugstatus: accepted labels 2025-12-29 18:32:43 +01:00
adam closed this issue 2025-12-29 18:32:43 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4035