Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG image upload fail for rear/front image in device types #5433

Closed
netixx opened this issue Dec 9, 2020 · 3 comments
Closed

SVG image upload fail for rear/front image in device types #5433

netixx opened this issue Dec 9, 2020 · 3 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@netixx
Copy link

netixx commented Dec 9, 2020

Environment

  • Python version: 3.8.6
  • NetBox version: 2.9.9

Steps to Reproduce

  1. Edit a device type
  2. Select an SVG file as a rear or front
  3. Save the form

Expected Behavior

Image is uploaded and save with the device type

Observed Behavior

Error returned on the image field :
Upload a valid image. The file you uploaded was either not an image or a corrupted image.

We are using the file storage backend. We also tried SVGZ format which didn't work as well.
PNG upload works fine.

@jeremystretch
Copy link
Member

This is due to lack of support for SVG in the PIL library, which is used by Django's ImageField for validation (see Django bug #14092).

Changing the front_image and rear_image fields on the DeviceType model to FileFields would allow for SVG upload, however custom validation would be needed to ensure uploaded files are valid images.

@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: bug A confirmed report of unexpected behavior in the application labels Dec 9, 2020
@netixx
Copy link
Author

netixx commented Dec 9, 2020

Thank you for the update. In the meantime, could we restrict the image types in the image picker/system browser to supported types only ?

In my case, I was mislead because I saw "*.svg, *.svgz" in the filtered file types.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Dec 11, 2020
@jeremystretch jeremystretch self-assigned this Dec 11, 2020
@jeremystretch
Copy link
Member

In the meantime, could we restrict the image types in the image picker/system browser to supported types only ?

Yes, I think that makes sense. I'm going to limit the accepted file types to exclude SVG. Still happy to entertain moving away from ImageField to ultimately enable support for SVG, but as mentioned that will be more involved so it would need a separate FR.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants