Image choosers on featured icons and topic icons currently offer no restrictions on image formats that can be used/added to a dropdown. However, the backend/templates assume that they will be SVGs. We need to provide proper validation for this. We can use ImageChooser(validators=[MySVGValidator]) and write up the proper validator, such as with this Wagtail example.
A potential implementation:
from django.core.validators import FileExtensionValidator
def SVGImageFormatValidator(value):
return FileExtensionValidator(allowed_extensions=["svg"])(value)
However, this gets tricky with the relationships for featured topics, as we only have access to an integer that is the image’s FK.
Maybe removing the SVG assumptions on the backend and trusting the editors could also be a way forward… (although I don’t like this as much)
Image choosers on featured icons and topic icons currently offer no restrictions on image formats that can be used/added to a dropdown. However, the backend/templates assume that they will be SVGs. We need to provide proper validation for this. We can use
ImageChooser(validators=[MySVGValidator])
and write up the proper validator, such as with this Wagtail example.A potential implementation:
However, this gets tricky with the relationships for featured topics, as we only have access to an integer that is the image’s FK.
Maybe removing the SVG assumptions on the backend and trusting the editors could also be a way forward… (although I don’t like this as much)
┆Issue is synchronized with this Jira Story